This is the lambda literal introduced in Ruby 1.9:
irb> l = ->(v) { v }
This is equivalent to writing:
irb> l = lambda { |v| v } # => #<Proc: 0x00000001daf538@ (irb):1 (lambda)>
In the above example, it is used to provide a default block to the method, when none are specified, consider this:
def method(a, &c) c ||= ->(v) { v } c.call(a) end method(1)
source share