From: Thiel Chang Date: 2012-05-30T23:08:41+09:00 Subject: Re: Problem with duplicated values in writing to an array Hi Jan, Many thanks for your answer. For me it was a very frustating problem. I should reread the "Programming Ruby" and "The Well-Grounded Rubist" books.;-) Anyhow, I solved the problem by refactoring the code. I have introduced a Code class for the code-array and now I can put the code objects in the arr-array. Greetings, Thiel Op 30-5-2012 15:44, Jan E. schreef: > Hi, > > Variables are references in Ruby. When you assign the "code" array to > the "arr" array, then "arr" will contain this exact array. Not some kind > of "snapshot" of the "code" array at this point of time. > > So what you're actually doing is you assign the same array (referenced > by "code") to the first and second index of "arr". If you want to have > two independent arrays, you have to clone "code" first. >