From: dblack@... Date: 2003-01-24T20:57:38+09:00 Subject: Re: Silly idea: map-like method produces array Hi -- On Fri, 24 Jan 2003, Hal E. Fulton wrote: > ----- Original Message ----- > From: "WATANABE Hirofumi" > To: "ruby-talk ML" > Sent: Thursday, January 23, 2003 10:42 PM > Subject: Re: Silly idea: map-like method produces array > > > > % irb > > >> x, y, z = [0] * 3 > > => [0, 0, 0] > > >> a, b, c, d, e = [[]] * 5 > > => [[], [], [], [], []] > > >> s1, s2, s3 = ["hello"] * 3 > > => ["hello", "hello", "hello"] > > Ah, never thought of that! > > Too bad it requires an array... > the brackets make it a little uglier. That doesn't do what you want, though: irb(main):001:0> a,b,c = [[]] * 3 [[], [], []] irb(main):002:0> a[0] = 1 1 irb(main):003:0> b [1] I think eban's point was that * already has a defined behavior for arrays. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav