Subject: Re: shortcut for x = [x] unless x.is_a?(Array)
From: Jeremy Weiskotten <jeremy.weiskotten gmail.com>
Date: Wed, 12 Mar 2008 08:32:17 +0900
References: *
In-reply-to: *
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.
--
Posted via http://www.ruby-forum.com/.