From: Cameron McBride Date: 2008-02-04T21:18:07+09:00 Subject: Re: creating a 2d array On Feb 2, 2008 12:55 PM, Adam Akhtar wrote: > Hi im just coming to ruby from C albeit after many years of no > programming. Im trying the simple matrix problem to get used to dealing > with arrays in ruby. There is a matrix class in the stdlib. But if you're doing anything numeric, I'd recommend using NArray. > How do you create a blank 2d array? > > I want to ask the user for the number of rows and columns and then > create a blank 2d array using those dimensions. From there I'd populate > it with the users desired data. Todd's suggestion will work, but I prefer: rows, cols = 2,3 mat = Array.new(rows) { Array.new(cols) } Cameron