From: BearItAll Date: 2005-08-10T18:41:10+09:00 Subject: Re: NEWBIE QUESTION: pattern with nil On Wed, 10 Aug 2005 14:44:15 +0900, John Carter wrote: > On Wed, 10 Aug 2005, basi wrote: > >> Hello, >> I'm a bit tired typing: >> >> if a == "" or a == nil >> if a != "" and a !== nil >> >> I'm sure there is a Ruby way to do this. > > > class NilClass > def empty? > true > end > end > > if a.empty? > I vote for this one because a good programmer is a lazy sod. Where ever you would end up doing a thing more than once, write it is such a way that you never have to type it again.