Pushin each_line into array not working

Posted by zettt on Stack Overflow See other posts from Stack Overflow or by zettt
Published on 2010-06-08T09:01:13Z Indexed on 2010/06/08 12:52 UTC
Read the original article Hit count: 147

Filed under:
|
|

Hi,

I've got a weird issue with Ruby. I want to read data from a file and put the data then into an array. The weird thing is, it's working in another script which does basically, the same thing.

quoteArray = []
quoteFile = File.new("quotes.txt", "r") or die "Unable to open file..."
quoteFile.each_line { |line| quoteArray.push line }
puts quoteArray[0]

All I get out of this is an array with one element where the whole text file is in. What's wrong? Is it my machine? The text file? Any ideas?

Thanks in advance

© Stack Overflow or respective owner

Related posts about ruby

Related posts about array