From: Robert Klemme Date: 2003-06-23T17:34:33+09:00 Subject: Re: 2 dimentional array in ruby - niewbie How about an OO solution: class MultTable attr_reader :dim_x, :dim_y def initialize(dim_x, dim_y) @dim_x, @dim_y = dim_x, dim_y end def [](x,y); x*y; end def row(x) a=[] dim_y.times{|y| a << self[x,y]} a end def col(y) a=[] dim_x.times{|x| a << self[x,y]} a end end mt = MultTable.new(10, 10) mt.dim_x.times do |x| p mt.row(x) end Cheers robert "Jacek Podkanski" schrieb im Newsbeitrag news:NF5Ja.3024$425.126690@newsfep2-gui.server.ntli.net... > Please help > I want to create a multiplication table in ruby. > I want a 2 dimentional array > and the do something like that > > 2darray.new > for row in 1..10 > for col in 1..10 > 2darray[row,col]=row*col > end > end > > How do I do it in Ruby > -- > Jacek Podkanski