From: Matt Mower Date: 2005-01-08T19:17:22+09:00 Subject: Re: Strange behavior of hash key On Sat, 8 Jan 2005 10:00:58 +0000, Matt Mower wrote: > Hi Traz, > > On Sat, 8 Jan 2005 17:51:25 +0900, Traz wrote: > > >Because Hash uses Object#eql? to test for equality it makes them > > >different keys and hence your example fails. > > > > Matt, string keys have the same behaviour, no ? : > > >> "one".object_id > > => 22476232 > > >> "one".object_id > > => 22473868 > > > > I think the answer here is that String redefines the eql? method to > compare content instead of 'object_id' so String literal keys will > work. > Hmm... except that I tried a naive redefinition of Hash#eql? to: def eql?( o ); self == o; end; and the example still doesn't work. Guess I'm just wrong ;-) M -- Matt Mower :: http://matt.blogs.it/