From: Christian Boos Date: 2002-08-14T17:23:36+09:00 Subject: RE: Is this array operation correct? > -----Original Message----- > From: dblack@candle.superlink.net [mailto:dblack@candle.superlink.net] > Sent: Wednesday, August 14, 2002 4:39 AM > To: ruby-talk ML > Subject: Re: Is this array operation correct? > > > Hello -- > > On Wed, 14 Aug 2002, Maur�cio wrote: > > > Hi, > > > > I've tried this: > > > > a = Array.new(3,[]) => [[], [], []] > > a[1].push(3) => [[3],[3],[3]] > > > > ... > > It's as if you said: > > ar = [] > a = [ ar, ar, ar ] > ar.push(3) > > and then 'a' would look like: [[3],[3],[3]] > > > Then, do something like: Array.new(3).map { [] } Is there something shorter/more efficient? -- Christian