From: Michael Neumann Date: 2001-07-19T04:55:16+09:00 Subject: [ruby-talk:18065] Re: <=> and nil values Michael Davis wrote: > Hello everyone, > > I would like to request a change to the <=> method to support the > following: > > Nil <=> 1 == -1 > 1 <=> nil == 1 > nil <=> nil == 0 > nil <=> 'test' == -1 > 'test' <=> nil == 1 > To change nil <=> any Object is no problem. Just write: class NilClass def <=>( anObject ) anObject ? -1 : 0 end end nil <=> nil # => 0 nil <=> 'test' # => -1 nil <=> 1 # => -1 But the other way round is not that easy, because you have to change all <=> methods of Ruby's classes. Regards, Michael -- Michael Neumann merlin.zwo InfoDesign GmbH http://www.merlin-zwo.de