DEV Community

Discussion on: Ruby 3.1 – Shorthand Hash Syntax – First Impressions

baweaver profile image
Brandon Weaver Author

I mean I agree with you on the general premise that Symbol and String intermingling is confusing, but there's zero chance that gets changed due to the way Ruby works, and I've resigned to that. I've also had that argument several times, but originally in Ruby Symbols and Strings were much more different in terms of GC, memory, and identity. Because of that past it's impossible to change.

As far as this being the straw that broke the camels back? I would disagree. Keyword arguments have done this for a long time, the only difference now is that they can be used on "write" (creating a hash or calling a kwarg function) rather than "read" (kwarg function argument definition).

Thread Thread
vgoff profile image
Victor Goff

Even further than that, it is not only symbol and string as keys, but anything that responds to hash can be used as a key.