William James
2/13/2009 6:07:00 AM
Zoe Phoenix wrote:
> One problem I'm facing is how to read an array from a file.
puts IO.read("data2")
Nashville
Orlando
Tampa
Memphis
==>nil
p IO.readlines("data2")
["Nashville\n", "Orlando\n", "Tampa\n", "Memphis\n"]
==>nil
p IO.readlines("data2").map{|s| s.strip}
["Nashville", "Orlando", "Tampa", "Memphis"]
==>nil
p IO.read("data2").split( /\s*\n\s*/ )
["Nashville", "Orlando", "Tampa", "Memphis"]
==>nil