3 ms·
The worst part of ruby imo is the fact that a hash can have both string and symbol keys. Countless times I have encountered issues where a function takes an opt
by Polylactic_acid 6y ago
The worst part of ruby imo is the fact that a hash can have both string and symbol keys. Countless times I have encountered issues where a function takes an options hash and the callers use both string and symbols for the same key depending on which caller it is. I end up calling the function to convert to symbols all the time.
- rudolph9 6y agoActually, if my memory serves me, a ruby hash can use any object a key! And considering everything in ruby is an object (even the class `Object`) it’s really quite elegant
- vlunkr 6y agoThis seems to be getting downvotes? I don't know why, it's accurate. Anything can be a key in Ruby.
- tdeck 6y agoThis is why ActiveSupport (Rails) has Hash#with_indifferent_access and people use it all over the place.