From: "Wayne E. Seguin" Date: 2007-08-09T22:47:07+09:00 Subject: Re: Deep Clone of array? --Apple-Mail-3-54128659 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Aug 09, 2007, at 09:30 , Wayne E. Seguin wrote: > > > hashish = { :a => "a", :b => "b", :c => ["a","b","c"] } # some > arbitrary object with references to other objects > > hashish_deep_copy = Marshal.load( Marshal.dump( hashish ) ) > > hashish_deep_copy will then be a deep copy of hashish. > > I have a library that I include in my projects which defines a deep_copy method on object: class Object def deep_copy( object ) Marshal.load( Marshal.dump( object ) ) end end Also please note that this method has some limitations due to limitations of Marshall. For example you won't be able to really dump IO, Proc, Singleton, Binding and a few other objects (Read the Marshal docs for more info). I hope this also helps, ~Wayne s///g Wayne E. Seguin Sr. Systems Architect & Systems Administrator --Apple-Mail-3-54128659--