From: Tony Arcieri Date: 2010-10-14T08:26:33+09:00 Subject: Re: more idiomatic way to avoid errors when calling method on variable that may be nil? --001485f1e94e6885db049287ec09 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Oct 11, 2010 at 10:04 PM, Joel VanderWerf wrote: > You can get around this by putting ( ) around the whole if clause: > > var = (hash[key].downcase if hash[key]) > > It works because (... if ...) returns nil if the condition is false. > The parens are unnecessary. The "var" variable will be implicitly bound to nil if the if condition isn't true. -- Tony Arcieri Medioh! A Kudelski Brand --001485f1e94e6885db049287ec09--