From: Vladimir Dozen Date: 2002-03-15T19:53:25+09:00 Subject: Re: key comparision inside Hash ehlo. > | What I cannot get is why Object::hash cannot be used for key? I had to > | define my own hash() to force key to be found; why cannot Object::hash > | compute hash based on all object variables? This would simplify things > | a bit. > Because the default semantic of "eql?" is equivalence ("equivalence" > means true iff two objects are same object). Mmm. I guess you mean "equivalent", not "same": k1 = Coord.new(1,2) k2 = Coord.new(1,2) is different objects, but eql in sense of getting object by coordinates. > One possible new semantic is that if object is T_OBJECT then "hash" > and "eql?" test would be based on its class and instance variable > values. RCR? Oops, I fear, I cannot understand it. You express semantics in terms of realization, right? ;) All I want is that default Object::hash() method return same value for two objects having same number and names of object member variables, and same values of those member variables. For simple cases like above Coord class (where only @x and @y present) it would be enough, for complex classes programmer will have to write own hash(). I guess, it will not break things? dozen