From: Christoph Date: 2003-09-25T00:56:22+09:00 Subject: Re: Hashes as keys "Eugene Scripnik" wrote: ... > Yes, you are right. This was just a fast dirty example of redefining > #hash method. BTW, you have to use pair[0].hash instead of pair[0] and > pair[1].hash similiarly. And think about collisions that your hash > method will generate, I think it is too simple. Your probably right but if you really want a good and fast hash method you have to write this as an extension anyway and experiment a lot - here is a random (probably over-complicated and not necessarily good) variant def hash _h = length * (length +43) __h = 1 << 31 - _h >> 6 each {|k,v| _h += k.hsh^(v.hsh<< 2) __h ^= (k.hsh << 3) + v.hsh + k.hsh } _h + __h + _h ^__h end /Christoph