From: James Britt Date: 2005-03-07T03:47:08+09:00 Subject: Re: Noob:Objects as key in hash Jim Weirich wrote: > ... > The hash function should return an integer to be used for hashing. Your > version returns a string. One correction might be ... > > def hash > [@x.object_id, @y.object_id].to_s.hash > end > > That will now work. But you probably really don't want to bother converting > the above to a string. Why not just do: > > def hash > @x.object_id + @y.object_id > end Isn't this the same value as @y.object_id + @x.object_id giving, for example, PointID.new( 1, 2).hash == PointID.new( 2, 1).hash But they are different coordinates. James