From: Joel VanderWerf Date: 2002-07-08T02:43:06+09:00 Subject: Re: Pre-RCR... nil.empty? Dave Thomas wrote: > It's a bit like the story of laying out the paths in the newly > constructed campus. The architect said "don't lay any concrete > paths. Just cover all the area between the buildings with grass." A > year later, the grass had worn to show where people actually walked, > and that's where they then poured the paths. Hm, the way that story finished (perhaps apocryphally?) is that after the concrete dried people still made their own paths in the grass... > > I'm suggesting that is an idiom is common enough we should perhaps > consider setting it in concrete. Guess I haven't done enough cgi to feel strongly one way or the other. Maybe that suggests it's cgi that should change? It could define a constant, Empty, or CGI::Entry::Empty or something, to be an object that responds to string messages as you want nil to. This might even include methods like #sub, #translate, etc, in addition to #empty? so you can safely do the following without checking for the nil case: string = cgi['field'][0] case string.downcase! # no need to check for nil when "ruby" puts "You win!" when CGI::Entry::Empty puts "Try typing in the Language field before you press submit." else # can now assume string.is_a? String puts "I don't recognize the language #{string.inspect}." end