Earlier quoted context omitted.
> but I tend to write very functional code A bit offtopic, but since you said that and you seem to be both fond of functional programming and in touch with latest ruby developments, you're probably a good person to ask: How the heck do you do "normal/proper" currying in Ruby? And how do you do it with keyword arguments? (I'm trying to compile a list of functional-idiom examples in popular dynamic language, and when I…
Ruby only has built-in support for currying procs: >> add = -> x, y { x + y } => # >> add.call(3, 5) => 8 >> add.call(3) ArgumentError: wrong number of arguments (1 for 2) >> curried_add = add.curry => # >> add_three = curried_add.call(3) => # >> add_three.call(5) => 8 If you want a no-brainer way of currying methods , you're SOL.
"Hello".method(:split).to_proc.curry[""]
=> ['H', 'e', 'l', 'l', 'o']
If you want to even make the receiver an argument it would take a little more hoop jumping, but with a tiny monkey patch you can enable something like this: "Hello".curry.split[""]