From: Rodrigo Rosenfeld Rosas Date: 2011-05-30T21:18:55+09:00 Subject: [ruby-core:36582] Re: [Ruby 1.9 - Feature #4801][Open] Shorthand Hash Syntax for Strings Em 30-05-2011 09:05, Michael Edgar escreveu: > Since :"#{abc}" is allowed in Ruby, I imagine that any such substitute syntax would preserve that property. > > I disagree strongly that Hash, the base class, should special-case the behaviors > of Strings and Symbols to be equal. It's a hash table, like those encountered in any other language, > and shouldn't behave unlike typical hash tables. Namely h[a] and h[b] look up the same > value iff a == b (or a.eql?(b), or whichever equality test you use). Strings and symbols > are never equal. Maybe, if we introduced another equality operator for comparing strings and symbols, let's say ### (I know this is a terrible representation, but I don't care about it now - just the idea): :"some-symbol" ### 'some-symbol' => true Unless one of them is not a symbol, it would work as always: 123 ### '123' => false 123 ### 123 => true Or maybe this operator should have a similar behavior for comparing numbers too. For instance, in Perl and other languages, if I remember correctly, hash[1] == hash['1'], and I think this is a good thing. After defining how this operator should behave, than the hash implementation would be typical anyway. I'm not proposing to change this in Ruby because of current existent written code that would probably be broken by such a change, but if this had been the decision from the beginning it would be fantastic!