From: Michal Rokos Date: 2001-11-19T07:09:26+09:00 Subject: [ruby-talk:25794] Re: Array.new(n, Array.new(m)) weirdness, but "select isn't broken" Hello! Chris Reay wrote: > irb(main):001:0> a = Array.new(3, Array.new(3)) > [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]] > irb(main):002:0> a[1][1] = 0 > 0 > irb(main):003:0> a > [[nil, 0, nil], [nil, 0, nil], [nil, 0, nil]] You've maybe forget that you have 3 references to the same array in the outhern array. So the change in one array affects all arrays. It's the same as: a = b = [1,2] a[0] = 0 b Is it cleaner now? Michal -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Michal Rokos Czech Technical University, Prague E-mail: m.rokos@sh.cvut.cz ICQ: 36118339 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-