From: Todd Benson Date: 2008-03-11T08:19:04+09:00 Subject: Re: shortcut for x = [x] unless x.is_a?(Array) On Mon, Mar 10, 2008 at 6:11 PM, Todd Benson wrote: > On Mon, Mar 10, 2008 at 5:57 PM, Siep Korteling wrote: > > Aryk Grosz wrote: > > > Is there any prettier or cleaner way to write > > > > > > x = [x] unless x.is_a?(Array) > > > > x = x.to_a > > > > Or am I overseeing something? > > > > Regards, > > > > Siep > > #to_a can behave differently > > x = {} > x = x.to_a > => [x] > > x = {} > > x = [x] unless x.is_a?(Array) > => [{x}] > > x = 5 > x.to_a > => some warning about default to_a being deprecated I should add, too, that Array[] is different than Array(). Todd