From: Robert Klemme Date: 2006-05-24T01:05:58+09:00 Subject: Re: Read File Into An Array 2006/5/23, Daniel Harple : > On May 23, 2006, at 5:43 PM, Robert Klemme wrote: > > > Why do you settly with a complicated version? IO.readlines() will > > perfectly suit your needs. If you want to do it while iterating > > yourself you should at least use the block form of File.open(). > > or IO::foreach: > > IO.foreach("somefile") do |line| > ... > end > > anonymous ruby-forum user wrote: > > That did it - thanks! :-) > > f = open("somefile") > contents_array = [] > f.each_line { |line| contents_array << line } > f.close > > or: > > contents_array = IO.readlines("somefile") > > Which looks better? I don't accept your second variant because you didn't use the block form. :-)) robert -- Have a look: http://www.flickr.com/photos/fussel-foto/