From: Cec Tre Date: 2010-03-19T09:26:43+09:00 Subject: problem making an array of arrays (of arrays) Hey, bit of a ruby noob here :) First, hello ruby-forum community. So, here is my problem. I want to create a 5x5 grid, however, each of the 'cells' in the grid should be able to hold a variety of values. Firstly, I started off with this: @row_1 = ['x','x','x','x','x'] @row_2 = ['x','x','x','x','x'] @row_3 = ['x','x','x','x','x'] @row_4 = ['x','x','x','x','x'] @row_5 = ['x','x','x','x','x'] @grid = [@row_1,@row_2,@row_3,@row_4,@row_5] So, obviously this creates a 5x5 grid, in which each of the 'cells' or @row_1..5[1..5] == 'x'. I used to just alter the string value in each cell by using: @grid[y][x] = 'new string' But, I ultimately want each cell to be an array.. So that I can push and pop their values as they change, and then the grid will always display the last value in the array, by using: @row_1 = [array.last,array1.last,array2.last,array3.last] #etc etc etc... My problem then is, that I have a different variable name for each of the five points in each of the five rows. So, the solution I really want is: Is it possible to have a variable called, say... cellxx ... Then, some piece of code that alters the xx part of the actual variable name itself? Because, I'm going about implementing cell00, cell01, cell02, cell03 etc etc each as an array and my code is getting messy. Please is there an (easier) way, to do what I want? Sorry for the length of this, you can tell i'm new to ruby :) Thanks! -- Posted via http://www.ruby-forum.com/.