From: Hassan Schroeder Date: 2011-03-16T07:43:32+09:00 Subject: Re: Making an array of arrays? On Tue, Mar 15, 2011 at 3:23 PM, Jen wrote: Just as an aside -- this seems awfully "un-ruby-ish" style -- > #When the for loop can take the value from pop must subtract 1 from it to > avoid having to do nasty index manipulation on the array > i = 0 > #Define an offspring array that will hold the copies of the @board array > @offspring = Array.new > for i in 0..3 > @offspring[i] = @board.clone > end @offspring = [] 4.times{ @offspring << @board.clone } But regardless, > ##Loop through @offspring and where ever there is "_" put a random number. > i = 0 > for i in 0..80 > if @offspring[i] = "_" The line above is *assigning* (=) a value, not testing for one (==). > then @offspring[i]= 9 > @offspring.inspect simply prints out a line of 9s. Yep, that's what it'll do :-) HTH! -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com twitter: @hassan