From: Robert Klemme Date: 2005-11-10T23:37:13+09:00 Subject: Re: Numeric <=> daz wrote: > Robert Klemme wrote: >> daz wrote: >>> >>> but it's able to tell that a == c which might >>> be enough to keep a routine running. >> >> Definitely not: >> >>>> ar=(0..2).map { Roo.new } >> => [#, #, #] >>>> ar.sort >> ArgumentError: comparison of Roo with Roo failed > > > Those instances are all different. The change only helps > by detecting equality, which is possible when a == a: But for detecting equality there's already == and eql?. And these methods are used where equality is needed (namely in a hash). No need to have a crippled <=>. > class Roo < Numeric; end > a = Roo.new > p [a,a].sort # [#, #] > > - Better than: > "I can't sort these, I don't know what they are." I beg to differ: IMHO it's better to make this case raise an error because that way it's more likely that a missing implementation of <=> is detected. >>> * numeric.c (num_cmp): added to satisfy Comparable assumption. >> >> Hm... Doesn't sound as if the assumption was satisfied... >> > > Nothing deep here, I think - just a tiny kink removed :-? Kind regards robert