How to do a newline in output How to do a newline in output ruby ruby

How to do a newline in output


Use "\n" instead of '\n'


You can do this all in the File.open block:

Dir.chdir 'C:/Users/name/Music'music = Dir['C:/Users/name/Music/*.{mp3, MP3}']puts 'what would you like to call the playlist?'playlist_name = gets.chomp + '.m3u'File.open playlist_name, 'w' do |f|  music.each do |z|    f.puts z  endend


I would like to share my experience with \n
I came to notice that "\n" works as-

puts "\n\n" // to provide 2 new lines

but not

p "\n\n"

also puts '\n\n'
Doesn't works.

Hope will work for you!!