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

核能气质少年 提交于 2019-12-23 20:03:11

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/7369553/jruby-is-ruby-lambda-syntax-not-an-important-consideration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!