hashie/hashie

[Question] Why use :to_sym in Hashie::Mash#convert_key

YasuakiOmokawa opened this issue · 1 comments

Hello, I have a question at below:

hashie/lib/hashie/mash.rb

Lines 373 to 375 in c297afb

def convert_key(key) #:nodoc:
key.respond_to?(:to_sym) ? key.to_s : key
end

I don't know why use :to_sym. In this case should use :to_s. What do you think?

See #521 for the reason. This attempts to only convert keys that should be converted. It leaves other keys alone.

What many people forget is that Mash is still a Hash and weird things happen when you try to use it as such.

I'm going to close this because it's retreading old ground. That being said, I'm curious about your thinking. Why do you think it should be #to_s?