Reputation: 61
For example, initialize the entire array to 0 or any other value.
[
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
]
Upvotes: 1
Views: 56
Reputation: 30056
Sure
Array.new(3) { Array.new(4, 0) }
=> [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
Upvotes: 3