Is currying just a way to avoid inheritance?
Posted
by Alex Mcp
on Stack Overflow
See other posts from Stack Overflow
or by Alex Mcp
Published on 2010-04-27T23:18:17Z
Indexed on
2010/04/27
23:23 UTC
Read the original article
Hit count: 448
currying
|language-agnostic
So my understanding of currying (based on SO questions) is that it lets you partially set parameters of a function and return a "truncated" function as a result.
If you have a big hairy function takes 10 parameters and looks like
function (location, type, gender, jumpShot%, SSN, vegetarian, salary) {
//weird stuff
}
and you want a "subset" function that will let you deal with presets for all but the jumpShot%
, shouldn't you just break out a class that inherits from the original function?
I suppose what I'm looking for is a use case for this pattern. Thanks!
© Stack Overflow or respective owner