From: Austin Ziegler Date: 2002-11-09T08:34:39+09:00 Subject: Re: Multi-dimensional (like 2) arrays in Ruby On Sat, 9 Nov 2002 08:18:31 +0900, Ted wrote: > All of the replies say the same thing -- this is good. My learning > project for Ruby is implementing a turning grille cipher. I want > to allocate a n*m matrix where n and m are read from stdin. > > I have the n[] (the rows) array, no sweat. But the m part (the > columns) is rather elusive. > > Here's my latest code: > > @m = Array.new(@rows) > @M = @m.each {|row| @m[row] = Array.new(@cols)} Try: matrix = Array.new(@rows, Array.new(@cols)) -austin -- Austin Ziegler, austin@halostatue.ca on 2002.11.08 at 18.29.35