From: ara.t.howard@... Date: 2006-08-09T23:13:19+09:00 Subject: Re: why doesn't Array include Comparable On Wed, 9 Aug 2006, Hal Fulton wrote: > Offhand I would guess it's because arrays can > hold arbitrary objects. > > If one array held four different classes of > objects, and another held yet another four > classes of objects, that's potentially sixteen > spaceship operators that would need to be > defined for this to make sense. And most of > those would not make sense anyway. i don't understand - it's up to to the objects inside the container to impliment the right methods and array already knows how to handle it: harp:~ > cat a.rb a = 0, 'foo', 42 b = 1, 'bar', 42.0 p a < b rescue puts "can't do that" class Array; include Comparable; end p a < b p a.sort_by{ rand } < b.sort_by{ rand } harp:~ > ruby a.rb can't do that true a.rb:9:in `<': comparison of Array with Array failed (ArgumentError) from a.rb:9 if you're collections impliment <=> correctly then Array does the right thing - looping over each of them. -a -- to foster inner awareness, introspection, and reasoning is more efficient than meditation and prayer. - h.h. the 14th dali lama