In Ruby, all objects are references. Take a look at the following example:
class Klass
attr_accessor :a
end
s1 = Klass.new
a = [1,2,3]
s1.a = a
s2 = s1.clone
s1.a.object_id #=> 7344240
s2.a.object_id #=> 7344240
You can see that both of the arrays are the same object, and are both references to the array living somewhere in the heap. In a deep copy, the array itself would have been copied, and the new s2
would have its own, distinct array. The array is not copied, just referenced.
Note: Here's what it looks like if you do a deep copy:
s3 = Marshal.load(Marshal.dump(s1)) #=> #<Klass:0x00000000bf1350 @a=[1, 2, 3, 4], @bork=4>
s3.a << 5 #=> [1, 2, 3, 4, 5]
s1 #=> #<Klass:0x00000000e21418 @a=[1, 2, 3, 4], @bork=4>