From: David Alan Black Date: 2002-07-08T03:06:24+09:00 Subject: Re: Pre-RCR... nil.empty? Hi -- On Mon, 8 Jul 2002, Avi Bryant wrote: > Dave Thomas wrote in message news:... > > Working with CGI forms and databases, it's something of a pain having > > to do > > > > string = cgi['field'][0] > > > > if string.nil? || string.empty? > > error "Please specify a value for 'field'" > > end > > > > etc etc... > > > > Would it be silly to have a predefined method: > > > > def nil.empty? > > true > > end > > Since there seems to be some opposition to this, how about > > def nil.empty_or_nil? > true > end > > class Object > def empty_or_nil? > empty? > end > end Interesting that this discussion sort of swirls around an old issue -- namely, the fact that in Ruby empty strings are true. (I'm not adducing this as evidence that they should be false -- just observing that that's the territory we seem to be on.) I keep thinking it feels like there's some way that to_str could play a role here... but haven't thought of it yet. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav