From: Robert Klemme Date: 2010-10-11T19:58:19+09:00 Subject: Re: Some newbie questions - bare with me ;) On Mon, Oct 11, 2010 at 12:15 PM, egervari wrote: > Ah, thanks for all of those answers. It helps very much. I didn't know > I could override == instead of eql?, and this fixed the problem with > RSpec ;) Makes much more sense, and I'd rather use == than equals, or > eql. I'm glad that it's not just a bad design decision carried over > from Java that even Java should not have had in it's original design. But please note that #== in Ruby is not the same as == in Java. Ruby's #equal? compares for object identity (in Java ==). Methods #== and #eql? are (most of the time) just two ways to access the same underlying logic. If you implement #== you should also implement #eql? because the latter method is used by Hash and Set (see my blog article that Jesus referred you to). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/