Project

General

Profile

Actions

Bug #6158

closed

Enumerator::Lazy#take: should it be lazy?

Added by Eregon (Benoit Daloze) about 12 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-03-15 trunk 35042) [x86_64-darwin10.8.0]
Backport:
[ruby-core:43344]

Description

Hello,

I noticed #take is now defined on Enumerator::Lazy, and it has lazy behavior:

(1..1000).lazy.select(&:even?).take 3 # => #<Enumerator::Lazy ...>

I would expect #take to not be lazy and always produce an Array, like the original Enumerable#take does.
I think many rubyists would expect that too.

Do you have a use case for a lazy #take ? I can't find one right now.

I've seen #6152, although I can't read it.
I think lazy.take(5) should be equal to lazy.first(5) and it reads better.


Files

lazy_bang.diff (1.11 KB) lazy_bang.diff gregolsen (Innokenty Mikhailov), 03/17/2012 07:36 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0