From: Adriano Ferreira Date: 2005-05-06T02:07:24+09:00 Subject: Re: Whats so different about a Hash? > Hm, I'm okay with the last part (checking if all pairs are shared), but > I'd replace the h1, h2 stuff with self.size == other.size. Agreed. That was unnecessarily complicated. That should do it: class Hash def eql?(b) return (self.size==b.size) && self.all? { | k, v | v.eql?(b[k]) } end def hash return self.inject(0) { | h, k, v | h ^ k.hash ^ v.hash } end end The Hash#hash is a suggestion for a hash method which obeys h1.hash==h2.hash if h1.eql?(h2). None of the methods above rely on sorting and other expensive operations, even though traversing the hash and possibly recursion (if there are hashes inside hashes) is expensive enough. Regards, Adriano.