From: Joel VanderWerf Date: 2010-10-14T07:23:44+09:00 Subject: Re: more idiomatic way to avoid errors when calling method on variable that may be nil? On 10/13/2010 10:30 AM, Charles Calvert wrote: > On Mon, 11 Oct 2010 23:04:59 -0500, Joel VanderWerf >> var = (hash[key].downcase if hash[key]) >> >> It works because (... if ...) returns nil if the condition is false. > > While that would clearly work, it makes me a little nervous as it > isn't immediately obvious, to me at least. Most likely I just haven't > spent enough time with Ruby. :) I agree. It reduces readability, and it's easy to forget the parens.