From: Trans Date: 2006-07-23T23:15:10+09:00 Subject: Re: Symbols vs. strings as hash_keys - interchangeable or not? Sean O'Halpin wrote: > On 7/22/06, transfire@gmail.com wrote: > > As Ezra points out they are not the same in Ruby. A hash key can be any > > object whatsoever. It could even be a number or another hash: > > > > { {:a=>1} => 'yep' } > > > Not meaning to be picky ;) but your example is a bit misleading. Consider: > > h1 = { {:a => 1} => 'nope'} > p h1[{:a => 1}] > #=> nil > hk = {:a => 1} > h2 = {hk => 'yep'} > p h2[hk] > #=> "yep" > > The problems of using hashes as keys has come up a few times - see > e.g. ruby-talk:167185 for one solution. Or you could just use: Huh? I didn't know that. Why isn't one hash "eql?" to another that has "eql?" elements? T.