Hello,
There's a behavioral difference between JRuby and MRI when calling #each. If a lambda with a return statement is called inside #each, the result of the latter will be returned rather than the lambda's one:
require 'minitest/autorun'
class LambdaTest < Minitest::Test
def bar(&b)
[1].each { -> { self.instance_exec(&b) }.call }
end
def test_return_with_lambda
assert_equal "foo", bar { return "foo" }
end
end
Have a nice day!
Hello,
There's a behavioral difference between JRuby and MRI when calling
#each. If a lambda with areturnstatement is called inside#each, the result of the latter will be returned rather than the lambda's one:Have a nice day!