From: Robert Feldt Date: 2003-09-14T09:25:37+09:00 Subject: Re: Ruby Object Model bothering me 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