11
I have a list containing new lines and I like to convert it into an array, e.g.
JAN
FEB
MAR
APR
MAY
into ["JAN", "FEB", "MAR", "APR", "MAY]
Any help will be appreciated. Thanks
Something like this doesn't seem to work (text_file.txt contains a list of months as above)
file = File.new("text_file.txt", "r")
while (line = file.gets)
line.chomp
list = line.split(/\n/)
puts "#{list}"
end