Skip to content

More information on currying

Currently currying is only mention twice on the documentation, both on the async lib section. Maybe more info on how the implementation works and uses cases could leverage more the feature

I've encountered a possible use case on returning a scope with a method that needed to access the parent methods parameters

methodA = (paramA) -> {
  {
    methodB = (paramB) -> paramA == paramB
  }
}

console.log(methodA(1).methodB(1))

(the returned scope have more methods, just showing one here for clarity. If it was just one method would be an even better case of currying, right?)

Because paramA would resolve to null on the running methodB. I was able to resolve passing paramA to the returned scope

{
  paramA

  methodB = (paramB) -> paramA == paramB
}

But maybe would be a good use case for currying (even thought i don't think this is a bad solution)