On 3/15/07, Trans [email protected] wrote:
all that it does. If NilClass were comparable per the above then
Infinity and _Infinity would be a better fit, I agree. But is it
return -1 if Infinity == other
Will that be good enough? People will often write their #<=> in classes.
Better than nothing of course.
if (c = super) != 0 then return c
I really hate not having more time and/or knowledge.
I had talked about this twice on the list but the second time (the
peak of the iceberg) I never found the time to elaborate.
I am very unhappy with the <=> paradigm for Comparable I really prefer
the Less Pattern (no idea why it has that name, maybe I recall
incorrectly) should be LessEqual.
Tom I guess you are familiar with it - I have posted this before, sorry
relies on #<= only
def < other; self <= other && ! other <= self end
def > other; other <= self && ! self <= other end
def >= other; other <= self end
def == other; other <= self && self <= other end
def != other; ! self == other; end
At first sight there are two major advantages, we can use it for half
orders where neither x <= y nor y <= x hold !
And more important in your context the module Comparable enforces the
symmetry of the #<= method, it does not show up later when you are
Performance of course is a catastrophe