From: "David A. Black" Date: 2008-07-04T10:17:56+09:00 Subject: Re: How to duplicate elements in array? Hi -- On Fri, 4 Jul 2008, phlip wrote: >>> a2 = a.dup + a.clone >> >> That gives the same result as his example. > > Indeed - it only cloned the top level of a, which is an array. The rest > remained a linked-too object. > > How to deep clone? The most common idiom for deep copying is: copy = Marshal.load(Marshal.dump(original)) David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails July 21-24 Edison, NJ Advancing With Rails August 18-21 Edison, NJ See http://www.rubypal.com for details and updates!