I have some Ruby code
def a(x, y)
puts x, y.call
end
a :a, -> do
[1, 2, 3].map! do |j|
j
end
end
I'm almost sure that it's correct, editor highlights it as correct, but I have such exception:
SyntaxError: (irb):6: syntax error, unexpected keyword_do_block, expecting keyword_end
[1, 2, 3].map! do |j|
^
(irb):9: syntax error, unexpected keyword_end, expecting end-of-input
doandendinstead of{}, since the block applies to the last expression here, not to theamethod call. And it works with{}instead ofdoandend. But it also works withdo/endand without inner block. So it may be a false trail.a(:a, -> do ... end){..}anddo..endare equivalent( )