From: Ruby Student Date: 2009-03-20T03:28:14+09:00 Subject: Re: Initializing an NxN array --0016e645b7683da85c04657d006e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Thu, Mar 19, 2009 at 1:36 PM, Evan Farrar wrote: > Evan Farrar wrote: > > Since * is defined on array, you can start with a 1x1 array and multiply > > to the size you need. > > > > > > n = 3; > > ary = [[0]*n]*n > > > > results in: > > ary => [[0, 0, 0], [0, 0, 0], [0, 0, 0]] > > whoops! that has the same problem mentioned above: > irb(main):026:0> ary[0][0] = :foo; ary > => [[:foo, 0, 0], [:foo, 0, 0], [:foo, 0, 0]] > > I retract! > -- > Posted via http://www.ruby-forum.com/. > > Thanks to all, your help is appreicated! -- Ruby Student --0016e645b7683da85c04657d006e--