4/16 arrays of arrays


#1


multi_d_array = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
multi_d_array.each { |x| puts "#{x}\n" }


How does the "#{x}\n" command work?



#2

This is a Ruby string containing a value interpolation block and a newline escape sequence.

"string"

#{value or expression}

\n  newline escape sequence

The latter is how we insert a line break (a form of white space). The output of the above array will look like this,

[0,0,0,0]
[0,0,0,0]
[0,0,0,0]
[0,0,0,0]