What is the operator & # 8594; (stab) in Ruby?

In the following example:

default: -> { Time.now } 

What -> ? I am familiar with => , but for the first time I see -> .

+40
ruby
Feb 18 2018-12-18T00:
source share
1 answer

This is a ruby ​​1.9-inch durable lambda. For example, see this article since 2008 .

Nutshell:

 > foo2 = ->(arg) { arg*2 } > foo2.call "now" => nownow 

Note the lack of space between -> and (arg) , which is intentional.

+49
Feb 18 '12 at 9:37
source share



All Articles