From: Son SonOfLilit Date: 2006-06-03T22:18:09+09:00 Subject: Re: []= and two dimensional arrays ------=_Part_16209_30587442.1149340685893 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Oi, got that all wrong. Correct version: I expect: > irb(main):002:0> a = Array.new.fill(Array.new.fill("x", 0, 4), 0, 4) > => [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], > ["x", "x", "x", "x"]] > irb(main):003:0> p a > [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", > "x", "x", "x"]] > => nil > irb(main):004:0> a[2][3] = "a" > => "a" > irb(main):005:0> p a > [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", > "x", "x", "a"]] > => nil > irb(main):006:0> > > ======================== > > I get: > irb(main):002:0> a = Array.new.fill(Array.new.fill("x", 0, 4), 0, 4) > => [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], > ["x", "x", > "x", "x"]] > irb(main):003:0> p a > [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", > "x", "x > ", "x"]] > => nil > irb(main):004:0> a[2][3] = "a" > => "a" > irb(main):005:0> p a > [["x", "x", "x", "a"], ["x", "x", "x", "a"], ["x", "x", "x", "a"], ["x", > "x", "x > ", "a"]] > => nil > > ========================= > > I spend hours debugging and when I find it out, I have no clue how to > solve it. > > Could somebody clue me as to a solution? > > Thanks, > > SonOfLilit > On 6/3/06, Son SonOfLilit wrote: > > I expect: > irb(main):002:0> a = Array.new.fill(Array.new.fill("x", 0, 4), 0, 4) > => [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], > ["x", "x", "x", "x"]] > irb(main):003:0> p a > [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", > "x", "x", "x"]] > => nil > irb(main):004:0> a[2][3] = "a" > => "a" > irb(main):005:0> p a > [["x", "x", "x", "a"], ["x", "x", "x", "a"], ["x", "x", "x", "a"], ["x", > "x", "x", "a"]] > => nil > irb(main):006:0> > > ======================== > > I get: > irb(main):002:0> a = Array.new.fill(Array.new.fill("x", 0, 4), 0, 4) > => [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], > ["x", "x", > "x", "x"]] > irb(main):003:0> p a > [["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", "x", "x", "x"], ["x", > "x", "x > ", "x"]] > => nil > irb(main):004:0> a[2][3] = "a" > => "a" > irb(main):005:0> p a > [["x", "x", "x", "a"], ["x", "x", "x", "a"], ["x", "x", "x", "a"], ["x", > "x", "x > ", "a"]] > => nil > > ========================= > > I spend hours debugging and when I find it out, I have no clue how to > solve it. > > Could somebody clue me as to a solution? > > Thanks, > > SonOfLilit > ------=_Part_16209_30587442.1149340685893--