From: Robert Klemme Date: 2010-06-12T17:55:04+09:00 Subject: Re: comparing objects On 06/11/2010 08:15 PM, Robert Dober wrote: > On Fri, Jun 11, 2010 at 6:47 PM, Robert Klemme > wrote: >> On 10.06.2010 18:27, Robert Dober wrote: >>> On Thu, Jun 10, 2010 at 6:10 PM, Robert Klemme >>> wrote: >>> >>>> http://blog.rubybestpractices.com/posts/rklemme/018-Complete_Class.html >>>> >>>> http://blog.rubybestpractices.com/posts/rklemme/019-Complete_Numeric_Class.html >>> I >>> You define #eql? and #hash for your convenience. So good, so bad. My >>> question simply was: Show my why *not* redefining #hash and #eql? will >>> cause problems, because that was Wilson's statement. I am still >>> waiting :(. >> The advice to implement #eql? and #hash really only makes sense if >> equivalence can reasonably be defined for a class and if instances of that >> class should be used as Hash keys or in Set. If not at least equivalence >> can be defined other than via identity (which is the default) then it is >> perfectly reasonable to not override both methods and go with the default >> implementation. > But that was *exactly* my point. I don't think we disagree, nor do I argue with you. I just posted blog links as illustration to Rein's point about how to implement those methods. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/