ruby new hash colon notation with string keys ruby new hash colon notation with string keys ruby ruby

ruby new hash colon notation with string keys


That's correct - the new colon notation for hashes only works when the keys are symbols.

Sorry, that's just how it is.

Update: general symbols are supported using the new notation in ruby 2.2 and later (strings as keys still aren't):

irb2.2.2 :001 > {'abc': 5}=> {:abc=>5}