From: Paul Lutus Date: 2006-10-23T01:15:15+09:00 Subject: Re: []= with moredimensional Arrays naPOLeon wrote: > Hi all, > > I want to code the "game of life" in ruby. I use a moredimensional > array Define "Moredimensional". Do you mean multidimensional? > as the field and another one to provide an easy way to input the > pattern of the start-population. (See the code below) > So my question is, whether there is a possibility to use ar[a..b][x..y] > = [[m, ...], [n, ...], ...]. That means, how can I merge two > 2-dimensional arrays? Define "merge." Leave nothing to the imagination. > > size = ARGV.first.to_i > field = Array.new(size, Array.new(size, 0)) > > thing = [[1, 1, 0, 1], > [1, 0, 1, 0], > [0, 0, 1, 0], > [1, 1, 0, 0]] > > pos_x, pos_y = size/2, size/2 > > field[pos_x..(pos_x + thing.length)][pos_y..(pos_y + thing.length)] = > thing Well, you have succeeded in stating what you don't understand. Now, please, just say what you want to accomplish. There is no question that you can do it using Ruby. -- Paul Lutus http://www.arachnoid.com