Convert bloc to lambda in JRuby

2020-07-18 03:07发布

问题:

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


标签: ruby jruby