From: Dan Doel Date: 2003-08-11T08:25:26+09:00 Subject: Re: Ruby and OOP-design (question of an old "procedural person" ;) Brian Candler wrote: >On Mon, Aug 11, 2003 at 03:16:55AM +0900, Dan Doel wrote: > > >>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? ... >> >> > >I think you mean 'if obj.notnil?' could be written that way. > > if obj... > >is equivalent to > > unless obj.nil? ... > >with the exception of obj == false. > >Cheers, > >Brian. > > > Right, of course. Most of the time it would be def nil? !self end Which would be a boolean anyway. Of course, it's even simpler than that, because you can do: class Object def nil? false end end class NilClass def nil? true end end So you really never save any typing at all. #nil? is a bad example, it seems. - Dan