William James wrote:
> 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.read("data2").split( /\s*\n\s*/ )
> ["Nashville", "Orlando", "Tampa", "Memphis"]
>     ==>nil


puts IO.read("data2.txt")

--output:--
Nashville
Orlando
Tampa
Memphis

p IO.read("data2.txt").split()

--output:--
["Nashville", "Orlando", "Tampa", "Memphis"]
-- 
Posted via http://www.ruby-forum.com/.