From: Yohanes Santoso Date: 2002-11-09T08:35:17+09:00 Subject: Re: Multi-dimensional (like 2) arrays in Ruby "Ted" writes: > 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| #=> warning, 'row' is always nil here > @m[row] = #=> == @m[nil] which is invalid > Array.new(@cols)} matrix=Array.new(@rows) 0.upto(@rows-1) {|i| matrix[i] = Array.new(@cols)} YS.