From: Todd Benson Date: 2008-03-12T10:00:37+09:00 Subject: Re: shortcut for x = [x] unless x.is_a?(Array) On Tue, Mar 11, 2008 at 6:32 PM, Jeremy Weiskotten wrote: > Aryk Grosz wrote: > > Is there any prettier or cleaner way to write > > > > x = [x] unless x.is_a?(Array) > > x = [x].flatten > > Although I suspect the x = Array(x) method would be faster. Yeah, but those are a little different, too... x = [[1, 2, 3], [1, 2]] p x.flatten => [1, 2, 3, 1, 2] x = [[1, 2, 3], [1, 2]] p Array(x) => [[1, 2, 3], [1, 2]] Todd