Convert bloc to lambda in JRuby

≡放荡痞女 提交于 2019-12-06 05:56:02

问题


How does one convert a bloc to a lambda in jruby? Basically what is the jruby answer for this: Ruby: convert proc to lambda??


回答1:


As long as you're running jruby 1.9-compatibly (e.g. jruby --1.9 -S irb), it should be the same:

my_proc = proc { |x| x }
my_lambda = lambda &my_proc
my_lambda.lambda?
# => true


来源:https://stackoverflow.com/questions/13239338/convert-bloc-to-lambda-in-jruby

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