开发者

jruby - is ruby lambda syntax -> not an important consideration?

开发者 https://www.devze.com 2023-04-04 02:28 出处:网络
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 syn

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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消