From: Yuguo Wang Date: 2001-07-31T21:32:02+09:00 Subject: [ruby-talk:18884] Re: Rubywin uses hard-coded "/cygdrive" prefix. Hi, all: I am a new user of Ruby. Could anyone please tell me why in the follwoing code, the string object is copied while the array is not. To my understanding, dup and clone both should do shallow copy. Thanks a lot. class A attr_accessor :str, :ary def initialize @str = "hello" @ary =[1,2,3,4] end def to_s puts "Str: #{@str}, Array: #{@ary} \n" end end a = A.new b = a.dup a.to_s ->Str: hello, Array: 1234 b.to_s ->Str: hello, Array: 1234 b.str = "Hello" b.ary[0]="cat" a.to_s ->Str: hello, Array:cat234 b.to_s ->Str: Hello, Array:cat234