lolix
lolix

Reputation: 1527

display array inside array in a table (view)

How can I display an array of array in a table (view) ?

matrix = Array.new(rows){Array.new(cols){0}}

like that:

0 0 0 0
0 0 0 0
0 0 0 0

Upvotes: 0

Views: 79

Answers (1)

Nabeel
Nabeel

Reputation: 2302

matrix = Array.new(3){Array.new(4){0}}

puts matrix.map {|x| x.join(' ')}

0 0 0 0
0 0 0 0
0 0 0 0

Upvotes: 1

Related Questions