在表中的数组内显示数组(视图)

时间:2016-02-24 18:24:04

标签: ruby-on-rails ruby

如何在表格(视图)中显示数组数组?

matrix = Array.new(rows){Array.new(cols){0}}
像那样:

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

1 个答案:

答案 0 :(得分:1)

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