Ruby: Write Array elements as new line


2018-01-17 · 1 min read

Use puts with an array argument to write each elements on a new line:

arr = %w[a b c]

File.open("array.txt", "w+") do |f|
  f.puts(a)
end

My Tech Newsletter

Get emails from me about programming & web development. I usually send it once a month