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:
1 9 6 15 7 19 18 3 0 12 13 20 18 15 0 3 19 1 14 16 7 16 5 3 12 19 4 9 20 10 6 10 9 1 18 17 7 19 5 15 12 3 8 16 10 5 2 18 20 6 12 9 0 18 2 11 16 8 7 15 8 9 14 19 3 16 6 20 13 17 7 19 16 14 13 6 9 2 3 5 10 17 8 15 11 2 13 14 16 7 14 9 20 17 15 3 4 2 11 19