T
Tim L
Can anyone explain why this code:
a = Array.new(3,Array.new(3,0))
a[1][1]=1
a.each {|r| puts r.join(', ')}
generates this output?
0, 1, 0
0, 1, 0
0, 1, 0
I was expecting this
0, 0, 0
0, 1, 0
0, 0, 0
Something wrong with my understanding of Ruby - or conceivably the set up on
my PC?
Tim L
a = Array.new(3,Array.new(3,0))
a[1][1]=1
a.each {|r| puts r.join(', ')}
generates this output?
0, 1, 0
0, 1, 0
0, 1, 0
I was expecting this
0, 0, 0
0, 1, 0
0, 0, 0
Something wrong with my understanding of Ruby - or conceivably the set up on
my PC?
Tim L