[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: What does it take to make an object hashable, no really...

Gavin Kistner

9/13/2006 4:29:00 PM

From: Tim Pease [mailto:tim.pease@gmail.com]
> On 9/13/06, Farrel Lifson <farrel.lifson@gmail.com> wrote:
> >
> > Is there a reason why an implementation of eql? is needed instead of
> > just being able to define <=>?
> >
> > Farrel
>
> The results of <=> are always a Fixnum -- specifically 1, 0, -1
>
> A Fixnum always evaluates to true in a boolean expression in Ruby.
> You have to use eql? if you want to get a true/false result.

Further, for some objects it's easy to say if they're equal or not, but
very hard to define if one is "greater than" the other or not. For
these, it's easy to define #eql? but impossible to define #<=>