From: Kirk Haines Date: 2010-10-12T05:17:27+09:00 Subject: Re: more idiomatic way to avoid errors when calling method on variable that may be nil? On Mon, Oct 11, 2010 at 2:05 PM, Charles Calvert wrote: > I'm using Ruby 1.8.7 patchlevel 249 > > Is there a more idiomatic way to do the following? > > var = hash[key].nil? ? nil : hash[key].downcase I see nothing wrong with an explicit approach. Here is an alternative, though: var = hash[key].downcase rescue nil Kirk Haines