I know this is probably not good Ruby style, but i'm learning... what's going on here? Specifically, why is the first row of my array a duplicate of the second row, when I think I'm initializing (copying) the values of the array parameter testa into @test, keeping all the indices the same?
class Test
def initialize (size, testa)
@test = Array.new(size, Array.new(size));
(1..size).each { |r|
(1..size).each { |c|
@test[r-1][c-1] = testa[r-1][c-1];
puts("#{r}, #{c}: #{@test[r-1][c-1]}");
}
}
end
end
t= Test.new(2,[[1,2],[3,4]]) #=> @test=[[3, 4], [3, 4]]