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
  • 165,429
  • 45
  • 277
  • 381
Thomas Koh
  • 213
  • 5
  • 17

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,591
  • 8
  • 14