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
If I'm not totally mistaken, you need to wrap the method call in parentheses like this
def a(x, y)
puts x, y.call
end
a(:a, -> do
[1, 2, 3].map! do |j|
j
end
end)
Now there still is problem that you are passing two parameters to puts where only one is allowed, so you would need to concatenate the string with + or some other way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With