This is a lambda literal. Check out this example:
> plus_one = ->(x){x+1} =>
Lambda literal is a constructor for Proc . A Proc
is a way to have a code block assigned to a variable. After that, you can call your code block again with different arguments as many times as you like.
Here's how you can pass a βfunctionβ as a parameter in a ruby. In many languages, you can pass a link to a function. In ruby ββyou can pass a proc object.
source share