consider this code
def f x, y
x + y
end
g = lambda(&method(:f)).curry.(1)
g.(2) # => 3
the expression for g
is too hard to read. Can it be simplified?
If you are using Ruby 2.2.0 or later, you can use Method#curry:
def f(x, y)
x + y
end
g = method(:f).curry[1]
p g[2] # => 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With