From: Iain Barnett Date: 2011-03-27T12:42:22+09:00 Subject: Re: shortcut for add unless nil ? On 26 Mar 2011, at 12:41, Aaron D. Gifford wrote: > I've found that whenever I have a variable that may be nil, doing > .to_i or .to_s or .to_a or something similar (so long as the NilClass > supports the type conversion I need) can come in handy. > > So for something like: > > big_array = array_or_nil_var1 + array_or_nil_var2 + array_or_nil_var3 > > I would just do: > > big_array = array_or_nil_var1.to_a + array_or_nil_var2.to_a + > array_or_nil_var3.to_a > > Aaron out. > Nice tip, thanks! Regards, Iain