1

I am trying to output two values in an array with new line.

list = []
list << "hello"
list << "\n";
list << "testing"
puts "#{list}"

This will give hello, \n, testing instead of the following output:

hello
testing

How can I output this array with a newline?

sawa
  • 160,959
  • 41
  • 265
  • 366
Thomas Koh
  • 203
  • 3
  • 16

1 Answers1

4
puts "#{list}"

This will print the array as it is, as a string.

puts list

This will print each element of the array in new line. This might be what you are looking for.

Nabin Paudyal
  • 1,533
  • 7
  • 14