From: matz@... (Yukihiro Matsumoto) Date: 2001-01-19T12:47:29+09:00 Subject: [ruby-talk:9536] Re: Strange Hash behavior Hi, In message "[ruby-talk:9533] Strange Hash behavior" on 01/01/19, "Agnot Tok" writes: |Why does: | |class C | def initialize(obj) | @o = obj | end | def hash | @o.hash | end | def inspect | @o.inspect | end |end | |h = {} |h[C.new(1)] = 1 |h[C.new(1)] = 2 |puts h.inspect | |evaluate to {1=>1, 1=>2} and not {1=>2}? |I thought Hash used the hash method?! Hash checks equality of keys by `hash' and `eql?'. Try to define both. matz.