From: Yohanes Santoso Date: 2002-12-17T06:38:42+09:00 Subject: Re: Deep copy in Rub? "MikkelFJ" writes: > clone is a flat copy. > In Ruby, any value deep or flat, integer or complex object, is stored in an > object as a reference. It doesn't make sense to say a value is flat or deep. > All references are simply copied using clone, not the content of the > references. Not what you want. When you do #clone, it really makes a duplicate of the object. The difference between a 'shallow copy' versus a 'deep copy' is the extent of the duplication. A shallow copy will only duplicate the #clone'd object. A deep copy duplicates the #clone'd object and recursively #clone all objects that it referes to. > Are you really sure you need deep copy? There are some valid usages, a few, not many. The easiest way to do deep copy is by using module Marshall: require 'marshal' a_copy = Marshal.load(Marshal.dump(the_original_object)) The pickaxe book has a more detailed documentation of this module. YS.