array = Array.new(10) { Array.new(10 , 0)}
array.each { |x| print x }
Prints out one single line of ten [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
.
If I were to change print
to puts
, I then get 100 0
down the page.
How do I print out each array on a separate line without the "[]" and ","?
Something like:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Suppose:
Then
is not very, er, attractive. For something more pleasing, you could quite easily do something like this:
If you have too many columns to display on the screen you can do this: