2009/12/6 Martin DeMello <martindemello / gmail.com>:
> On Sun, Dec 6, 2009 at 2:34 PM, David A. Black <dblack / rubypal.com> wrote:
>>
>> As others have said, there are better ways (mainly File.readlines). As
>> for map/collect in general: it's hard to come up with a useful value
>> when it's called without a block.
>
> The use case I can see is to turn an Enumerable into an Array. Which
> means that you should be using to_a instead, and checking,
> File.open("foo").to_a does indeed do the right thing.
Only that it misses closing the file properly. Rather to
File.readlines "foo"
which has been mentioned elsewhere in this thread.
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/