From: Gavin Sinclair Date: 2003-08-09T20:28:12+09:00 Subject: Re: Ruby and OOP-design (question of an old "procedural person" ;) On Saturday, August 9, 2003, 8:31:47 PM, Martin wrote: > Florian Frank wrote: >> >> def <=>(other) >> (self.freq <=> other.freq).nonzero? || other.time <=> self.time >> end > Shouldn't that be > def <=>(other) > a = (self.freq <=> other.freq) > a.nonzero? ? a : (other.time <=> self.time) > end > since calling nonzero? collapses [-1,1] to 'true'. Actually, I fancy def <=>(other) [self.freq, self.time] <=> [other.freq, other.time] end I don't know if it works, but I fancy it. Given what I know about Ruby, I'd be surprised if it *didn't* work. Gavin