Reputation: 25005
The colon hash syntax works:
{ abc: 5 }
# => {:abc=>5}
However, puts {abc: 5}
raises an error:
syntax error, unexpected ':', expecting '}'
puts {abc: 5}
^
I am using ruby 2.0.0. Why is that happening?
Upvotes: 1
Views: 91
Reputation: 168269
The {}
is recognized as a block. Put it in parentheses.
puts({abc: 5})
or
puts(abc: 5)
or
puts abc: 5
Upvotes: 4