Hi -- On Sun, 6 Dec 2009, Martin DeMello wrote: > 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. It will work (using map instead of to_a in 1.8), but I don't think it's a real use case, in the sense that it would never be the best way. In other words, there's a use case for what map without a block does, but not for using map to do it. I'm not sure there are any real uses for map returning an enumerator, as in 1.9, either. You can do: a = [1,2,3] e = a.map e.each {|x| x * 10 } # [10, 20, 30] but that's just a long way of writing map. David -- THE COMPLEAT RUBYIST, Ruby training with Black/Brown/McAnally! January 22-23, Tampa, Florida Info and registration at http://www.thecompleatrubyist.com -------------------------------------- My new job: http://tinyurl.com/yfpn9hz