From: "Iñaki Baz Castillo" Date: 2008-05-05T23:01:58+09:00 Subject: Recursive dup Hi, it seems that "dup" method is not recursive, so if we do: obj_b = obj_a.dup then all the attributes of obj_b will be a exact copy of attributes of obj_a, and not references. But if an attribute of obj_a is an object containing objects inside then those will be referenced and not copied. This is: -------------------------------- class A attr_accessor :att end class Obj attr_accessor :kk end obj = Obj.new obj.kk = "KAKA1" a=A.new a.att=obj a => #> b=a.dup => #> b.a.kk="KAKA2" a => #> ----------------------------------------- So finally, an attribute of an attribute of "a" is been modified when modifying "b". I know that I should personalize "dup" method for class A, but is not any other way? Does exist any automatic way of doing it? I expect some method "dup_recursive" that looks for objects into attributes recursively and clones them instead of reference. Is there something as it? Thanks a lot. -- Iñaki Baz Castillo