Hi --

On Tue, 10 Feb 2009, David A. Black wrote:

> Hi --
>
> On Tue, 10 Feb 2009, 7stud -- wrote:
>
>> In my opinion, it's nicer than the first version because it doesn't have
>> to create a sub array in memory, like all the solutions posted so far
>> do, which could be a problem with large arrays and large slices.
>
> Ryan had something like:
>
>  topics.first(5).each do |t|
>    puts t.title
>  end
>
> which, I believe, does not create an intermediate array because
> topics.first(5) returns an enumerator.

Rewind. As Tom points out, first(x) returns an array. (Which in fact
makes sense, since it's often used entirely on its own.)


David

-- 
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2)

http://www.wishsight.com => Independent, social wishlist management!