From: Robert Klemme Date: 2010-11-09T22:41:27+09:00 Subject: Re: shadow copy and deep copy 2010/11/9 Eva : > x=[1,2,3] > y=x.dup > > this is a shadow copy, I know the theory behind it. Actually it's called "shallow copy". And what #dup really does depends on the class so it could even implement a deep copy (although that is normally not the case). In the case of Array you are correct, it's a shallow copy. > z=x > > is this a deep copy? (z is the deep copy of x?) No, there is no copy of state at all. This is called "aliasing": now both z and x point to the same object. Example for deep copy: z = Marshal.load(Marshal.dump(x)) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/