From: Paul Mckibbin Date: 2011-03-04T11:28:05+09:00 Subject: Re: How to make copies of array that do not impact on the original? Jen wrote in post #985279: > Hi, > > I'm trying to make a sudoku solver that uses genetic algorithms in Ruby. > make copy of board in to board i > end > I want to end up with my copies named board1, board2 etc, depending on > the value of 'i' when the array is created from the original. > If I could do this in a simpler way with blocks please let me know. > > Thanks in advance for any suggestions. Wouldn't it be better to have arrays of boards rather than copies with names like board1, board2 etc. I'd do something like original_board=[1,2,3,4,5,6] board=[] n.times {board << original_board.dup} If the array contents are more comples (e.g. references to objects), then dup won't be good enough, but if it is primitives you are storing, that will make a copy. Paul -- Posted via http://www.ruby-forum.com/.