recursive deep copy

hello,

  It's a little bit hard question:   i've a problem when working on arrays. i'm doing a deep copy of an array (a find request result) by doing it : @array = new.Array(@original_array) it just copies the first level, under levels arrays and hashes are not include in deep copy!

some can help?

Hi --

Hi --

What about this :

new_array = old_array

He wants a deep copy, and that's neither deep nor a copy. It's just a new reference to the same array:

   array = [1,2,3]    new_array = array    new_array.push(4)    p array # [1, 2, 3, 4]

David

thank you guys, "@array = Marshal::load(Marshal.dump(@original_array))" works perfectly