From: Pieter Hugo Date: 2009-11-24T23:46:28+09:00 Subject: Difference between << and += for Strings and Arrays. Bug? Hi I have been programming with Ruby for about 1 year and am loving it. I cam across something that I can't figure out why it works the way it does: Eg: a=[1,2] b=a b << 3 The value of b is now [1,2,3], but the value of a is also [1,2,3]???? And yet: a=[1,2] b=a b += [3] The value of b is still [1,2,3] but a remains [1,2]. This just doesnt make sense to. The same happens with Strings. Why would the append operator (<<) change the original variable, but other operators dont seem to. PS What I really want to know is why the original variable is changed at all? -- Posted via http://www.ruby-forum.com/.