From: Martin DeMello Date: 2008-10-30T01:12:49+09:00 Subject: Re: Bug or not a bug? array*=int On Wed, Oct 29, 2008 at 8:30 AM, Kyle Schmitt wrote: > So I'm wondering, is this a bug, or not a bug, or a type-o in the docs? > > According to http://www.ruby-doc.org/core/classes/Array.html > array*int "[R]eturns a new array built by concatenating the int > copies of self." > Copies should be brand new independent copies, right? No, copies are shallow copies. Consider, for example irb(main):002:0> class A; attr_accessor :a; end => nil irb(main):003:0> a = A.new => # irb(main):004:0> a.a = 10 => 10 irb(main):005:0> foo = [a] => [#] irb(main):006:0> foo *= 3 => [#, #, #] irb(main):007:0> a.a = 20 => 20 irb(main):008:0> foo => [#, #, #] martin