From: Robert Dober Date: 2006-06-26T21:23:34+09:00 Subject: Re: Ruby and Java equality usage ------=_Part_47497_22162416.1151324608524 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 6/26/06, Alexandru Popescu wrote: > > Thanks Robert. I have used that information and I am even linking to > it. The problem I was facing was to explain why == and eql? are both > needed, and when their implementation may be different. > > Ok I knew I missed something. Personally I find it quite useful to have "==" which I can adapt to my needs, knowing that I can always count on "eql?" for object equality, I might do things like this: class MyString < String def ==( otherString ) raise SomeException unless String === otherString self.downcase.eql?( otherString.downcase ) end end x=MyString.new("Alfa") x == "alfa" ==> true x.eql?("alfa") ==> false Now I think it is perfectly sane to say, no I think this is confusing I will keep my "==" and my "eql?" identical. However be prepared that others will not ;) Cheers Robert ------=_Part_47497_22162416.1151324608524--