From: Stefan Lang Date: 2005-02-17T23:04:53+09:00 Subject: Re: A little bit confused about array+array addition (bug or expected behavior?) gga wrote: > irb(main):082:0> def add(x) > irb(main):084:1>    x += [5,6] This creates a new array and assigns it to the local variable x. The original array passed into this method won't be modified. But the result of the statement is the new array, which will be returned. > irb(main):085:1> end > > irb(main):087:0> add(a) > => [1, 2, 3, 4, 5, 6] > irb(main):088:0> a > => [1, 2, 3, 4]        ===>>> uh?  am I not passing stuff by reference? > where is 5, 6? > > > irb(main):089:0> def add2(x) > irb(main):089:0>   x << [5,6] << appends to the existing array > irb(main):089:0> end