F
felix chang
Dear all:
This is my code:
data = Array.new(5,[])
0.upto(4) do |i|
data.push(i)
end
p data
the output is :
[[0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0,
1, 2, 3, 4]]
I am so confused why the output is not that showed below
[[0],[1],[2],[3],[4]]
This is my code:
data = Array.new(5,[])
0.upto(4) do |i|
data.push(i)
end
p data
the output is :
[[0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0,
1, 2, 3, 4]]
I am so confused why the output is not that showed below
[[0],[1],[2],[3],[4]]