Christoph wrote:

>>$ cat myhash.rb
>>class MyHash < Hash
>>     def hash
>>         current = 17
>>         self.each do |k, v|
>>             current = current * 37 + k.hash
>>             current = current * 37 + v.hash
>>         end
> 
> 
> Your Hash is not (in this case each enumerate) order independent 
> either  (i.e. it's possible that  hash1 == hash2 is true but 
> hash1.hash == hash2.hash is false)  -  just use a simple summation
> on  the key-value pair similar to my previous post
> 
> def hash
>     inject(17) {|hsh,pair|  hsh + pair[0]^(pair[1]<< 2) }
> end
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.

-- 
Eugene Scripnik
IT Group
Software Architect
Tel./Fax +380 (372) 58-43-10
email: Eugene.Scripnik / itgrp.net
http://www.itgrp.net/