Subject: Re: make an exmpersion simpler
From: Jeremy Woertink <jeremywoertink gmail.com>
Date: Fri, 20 Nov 2009 06:16:02 +0900
References: 350975
In-reply-to: 350975
Michal Burak wrote:
> Any way to make this shorter?
>
> list2 << list1 if list1 && !list1.empty?
>
> Thanks.
if you know list1 will never be nil, then you can do
list2 << list1 unless list1.empty?
~Jeremy
--
Posted via http://www.ruby-forum.com/.