What do you call the
->
operator as in the following?->(...) do ... end
Aren't the following snippets equivalent?
succ = ->(x) {x + 1} succ = lambda {|x| x + 1}
What do you call the ->
operator as in the following?
->(...) do
...
end
Aren't the following snippets equivalent?
succ = ->(x) {x + 1}
succ = lambda {|x| x + 1}
In Ruby Programming Language ("Methods, Procs, Lambdas, and Closures"), a lambda defined using ->
is called lambda literal.
succ = ->(x){ x+1 }
succ.call(2)
The code is equivalent to the following one.
succ = lambda { |x| x + 1 }
succ.call(2)
Informally, I have heard it being called stabby lambda or stabby literal.