Hi Nick,

In your array2 << array1 statement, generally array2 object refers the 
object of array1. So that when you clear array1, the value in the 
referred object also gets cleared.

To avoid this, we can use dup method.

Try this:
a = [1, 2, 3, 4, 5]
b = Array.new
b << a.dup
a.clear
p b

will give you [[1, 2]].

Hope it helps you.

Cheers,
Vimal

-- 
Posted via http://www.ruby-forum.com/.