How do I make \n
actually work in my output? At the moment it just writes it all in 1 long block. Thanks for any help
Dir.chdir 'C:/Users/name/Music'
music = Dir['C:/Users/name/Music/*.{mp3, MP3}']
puts 'what would you like to call the playlist?'
@new = ''
playlist_name = gets.chomp + '.m3u'
music.each do |z|
@new += z + '\n'
end
File.open playlist_name, 'w' do |f|
f.write @new
end
You can do this all in the File.open block:
Use
"\n"
instead of'\n'
I would like to share my experience with
\n
I came to notice that "\n" works as-
but not
also puts
'\n\n'
Doesn't works.
Hope will work for you!!
Actually you don't even need the block: