From: Victor Shepelev Date: 2006-04-14T16:49:50+09:00 Subject: Re: Rubyesque way to do multiple <=> > >def <=> (other) > > res = ComplexCustomComparator.compare(sex, other.sex) > > return res if res != 0 > > > > #if they have the same sex, do other comparisons > >end > > > >Foooooo! > > > >How can I do the former in more elegant way? > > > > > def <=> (other) > ComplexCustomComparator1.compare(sex, other.sex).nonzero? || > ComplexCustomComparator2.compare(age, other.age).nonzero? || > # ... > ComplexCustomComparatorn.compare(foo, other.foo) > end Seems that return value would be wrong (true/false instead of -1|0|1) Victor.