On 6/26/06, Robert Dober <robert.dober / gmail.com> wrote:
> On 6/26/06, Alexandru Popescu <the.mindstorm.mailinglist / gmail.com> 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
>
>

Thanks for confirming my point :-). I couldn't find a
good/workable/meaningfull example for having different implementation
for == and eql?. I am still looking for.

./alex
--
.w( the_mindstorm )p.
---
(http://themindstorms.blogspot.com)