From: "Kurt M. Dresner" Date: 2003-09-14T11:31:47+09:00 Subject: Re: Ruby Object Model bothering me Yeah, that's what I meant. When I do a[i].push(foo) then all of a is foo. I forgot about the block for the constructor that gets run each time. Now I am a happy rubyist once again. -Kurt On Sun, Sep 14, 2003 at 09:25:37AM +0900, Robert Feldt wrote: > Dan Doel skrev den Sun, 14 Sep 2003 09:11:16 +0900: > > >Kurt M. Dresner wrote: > > > >>Ok, so I did > >> > >>a = Array.new(number, []) > >> > >>It's really bothering me that if I do a[i] = n, all of a is now n. > >> > >>Is there a graceful way to get around this? > >> > >> > > > >When I do: > > > >a = Array.new(6, []) > > > >a[5] = 3 > > > >p a[2] > > > >I get [] printed out. > > > Yeah, but what about > > a = Array.new(6, []) > a[5] << 3 > p a[2] > > ? ;) > > I think the original poster might wanna try > > a = Array.new(6) {Array.new} > > but I'm not sure I understand what he wants... > > Regards, > > Robert > > >- Dan > > > > > > > > > > > > -- > Robert Feldt > > >======= End of Original Message =======<