Printing an array of arrays on one line in console (one line per master array object) in Ruby

your_array.each do |person|
  puts person.join(" ")
end

The method puts will automatically put a new line. Use print instead to print the text out with no new line.

Or if you want, you can use the join function.

['a', 'b', 'c'].join(' ') 
=> 'a b c'

You can just iterate over the outer array and join the inner arrays into a string. Since you provide no example data ready for copying and pasting, here's some example code I made up:

outer_array.each { |inner| puts inner.join(' ') }

Tags:

Arrays

Ruby