Re:New Ruby 1.9 Features, Tips & Tricks
by pyrhho on Monday February 21, 2011 @04:05PM
(#2247175)
Conspicuously missing is the brilliant new Proc.curry method!
For those that don't know currying is a method that returns another Proc with one fewer argument, so you can do:
multiply = Proc.new { |x, y| x * y }
multiply_by_five = multiply.curry(5)
multiply_by_five.call(3) # => 15
For those that don't know currying is a method that returns another Proc with one fewer argument, so you can do: multiply = Proc.new { |x, y| x * y } multiply_by_five = multiply.curry(5) multiply_by_five.call(3) # => 15