From: Frederic Chalons - Design Support IA Student Date: 2003-05-21T17:24:13+09:00 Subject: Copying an Array Hi, The = operator seems to retrieve an reference on a Array rather than copying what it contains as in the following code: ******* a = [1,2,3] b = a p b.id; p a.id b.each_index do |i| b[i] *= 2 end ******** both a and b equals to [2,4,6] This can be solve by using a.collect or a.dup but the problem would occur again if a,b are multi dimensions Array. dup or collect reference on the sub-Array? Isn't there a clean and consise way to copy the whole content of an multi dimension Array so that the copy is not somehow linked to the original. Btw, a would be modified even though it is accessed as attri_reader. So I guess = is copying the pointer rather than any content (a.id == b.id) (using ruby 1.6.8 (2002-12-24) [sparc-solaris2.8]) Thank you, Fred