On Sat, 21 Jul 2001, Steve Hill wrote: > Hi, > in methods such as [], []=, fetch, etc. how does Hash locate a key, > value pair. > > For example, in > > h=Hash.new > h[0]="foo" > h[1]="bar" > > puts h[0] > > how does the Hash object h locate the appropriate pair. > > I ask this because I am having problems in getting a hash to work when > the keys are objects that I have created - in this case a Bin_key > object that holds the endpoints of a bin. I've tried defining a == and > a <=> method and I'm not getting anywhere. Here is my bin_key object Anytime you redefine ==, you need to redefine hash such that if a == b, a.hash == b.hash.