def foo
1,2
end
causes syntax error "unexpected ',', expecting keyword_end"
I'd think this is valid Ruby. What's wrong?
You're not returning an array.
You should have this:
def foo
[1, 2]
end
Ruby isn't expecting a comma (,) because it isn't valid syntax. Integers in a simple array should be surrounded by brackets as well as delineated by a comma.
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