In article <d563731905010802175d37f678 / mail.gmail.com>, Matt Mower wrote: >On Sat, 8 Jan 2005 10:00:58 +0000, Matt Mower <matt.mower / gmail.com> wrote: >> Hi Traz, >> >> On Sat, 8 Jan 2005 17:51:25 +0900, Traz <A.Reith / gmail.com > 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 ;-) You also need to define Hash#hash so that eql objects have the same hash code.