From: Aldric Giacomoni Date: 2009-11-20T22:07:30+09:00 Subject: Re: make an exmpersion simpler Tor Erik Linnerud wrote: > Michal Burak wrote: >> i wan add all elements from list1 to list2 > > That is not what your code does. > > This should work: > > list2.concat(list1 || []) If, however, we know that list1 _does exist_ as a variable, then >> list2.concat list1 is all we need. If list1 does not exist, your code will return an error, and so... >> list2.concat list1 rescue nil This will concatenate list1 and list2, unless list1 does not exist, in which case it'll return nil instead of an error, and list2 will remain the same. -- Posted via http://www.ruby-forum.com/.