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
精彩评论