From: James Edward Gray II Date: 2006-08-16T22:08:05+09:00 Subject: Re: Nooby question : multidimensional arrays. On Aug 16, 2006, at 4:37 AM, marinho.tobolla@syncity.de wrote: > Well am I right, that in Ruby there are only one dimensional > arrays, and that i have to add an array into an array to get > multidimensional arrays, or is there a simpler more ruby like way > to create them ? Others have given you great answers, but it's also worth pointing out that you can make a multidimensional Array, if you like: >> class Array2D >> def initialize(width, height) >> @data = Array.new(width) { Array.new(height) } >> end >> def [](x, y) >> @data[x][y] >> end >> def []=(x, y, value) >> @data[x][y] = value >> end >> end => nil >> arr = Array2D.new(3, 2) => # >> arr[1, 1] = "Hello" => "Hello" >> arr => # >> arr[1, 1] => "Hello" James Edward Gray II