I was working a project Euler problem and noticed that when I used this
code:

array1 = ["a", "b", "c", "d", "e"]
array2 = Array.new
array2 << array1
array1.clear
p array2

[[]] is my output. But, when I tried:

array1 = ["a", "b", "c", "d", "e"]
array2 = Array.new
array2 << array1
array1 = []
p array2

[["a", "b", "c", "d", "e"]] is my output.  I am not understanding why
clearing array1 is changing array2, but replacing the value of array1 is
having no effect.

(btw, using ruby 1.9.2p180)

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