From: Dan Doel Date: 2003-08-11T03:16:55+09:00 Subject: Re: Ruby and OOP-design (question of an old "procedural person" ;) ts wrote: >>>>>>"D" == Dan Doel writes: >>>>>> >>>>>> > >D> def nil? >D> self >D> end > > Sorry, but I really don't understand why you use #nil? because precisely > #nil? return true or false > > The original problem was with #nonzero? > >pigeon% ruby -e 'p 12.nonzero?' >12 >pigeon% > >pigeon% ruby -e 'p 12.zero?' >false >pigeon% > > It was just an example. #nil? could be written that way, although then it'd be pointless, since if obj ... Would be exactly the same as if obj.nil? ... The only difference would be some readability. But you could substitute #nonzero?, #zero?, #respond_to?, or any ? method for #nil? in my post and I think it would still apply, except that you don't save any typing for other methods. - Dan