From: timr Date: 2009-12-06T12:15:05+09:00 Subject: Re: ruby 1.9 and collect Where you have been using File.open("some_file").collect #in 1.8 Most ruby programmers probably would've used: File.readlines("some_file") It is shorter (by 3 whole characters), does the same thing as your code, and has the added benefit of not using collect in a quirky way. Array#collect is for sending data into a block and getting the result of the block back collected into an array. When used without a block the usage is opaque. And though terse it is hard to understand the implied {|x| x }. Try File.readlines("some_file"). Try it and you may I say. Try it, try it and you may... Tim On Dec 5, 9:40 am, Raul Jara wrote: > Under ruby 1.8.6, running > > [1, 2, 3].collect > > results in an array of [1, 2, 3].  In 1.9, however, running > > [1, 2, 3].collect > > results in an Enumerator, which I then have to call .to_a on. > Alternately, I can supply a block > > [1, 2, 3].collect {|x| x } > > and end up with an array.  So I guess that means that the default block > of {|x| x} was removed from the function.  I was just wondering if > anyone had any insight into why that change was made, because it feels > very counter intuitive to me.   I really liked the elegance of opening > up a file and just calling collect to turn it into an array. > -- > Posted viahttp://www.ruby-forum.com/.