jruby - is ruby lambda syntax -> not an important

2019-07-04 00:01发布

I noticed that new lambda syntax -> in Ruby 1.9 is not supported even in the latest 1.6.4 jruby release. So, I am guessing this syntax is not commonly used in the ruby community. Is it because the syntax is new or are there any other disadvantages?

x = -> y { y+1 }
x.call(2)

This returns 3 in ruby 1.9.1 and gives a syntax error in jruby 1.6.4

标签: ruby jruby
1条回答
一纸荒年 Trace。
2楼-- · 2019-07-04 00:37

You are not running it in 1.9 mode.

$ jruby --1.9 -S irb
irb(main):001:0> x = -> y { y+1 }
=> #<Proc:0x1e937f@(irb):1 (lambda)>
irb(main):002:0> x.call(2)
=> 3
查看更多
登录 后发表回答