From: "trans (Thomas Sawyer)" Date: 2012-04-01T03:47:23+09:00 Subject: [ruby-core:44026] [ruby-trunk - Feature #6166] Enumerator::Lazy#pinch Issue #6166 has been updated by trans (Thomas Sawyer). I don't care about name "#pinch", but functionality. Using #first with #drop is not always optimal. 1) Given d = [index,length]. enum.drop(d.first).first(d.last) 2) Given a range (e.g. `rng = 2...4`): if rng.exclude_end? enum.drop(rng.begin).first(rng.end-1) else enum.drop(rng.begin).first(rng.end) end `enum(*d)` and `enum(rng)` is much better. Also I take it #drop is lazy? ---------------------------------------- Feature #6166: Enumerator::Lazy#pinch https://bugs.ruby-lang.org/issues/6166#change-25553 Author: trans (Thomas Sawyer) Status: Rejected Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: In previous issue #6158 it has been determined that Enumerator::Lazy#take should be lazy. But an eager form of #take would still be useful. To this end I'll suggest `Enumerator::Lazy#pinch`. Examples of usage: e.lazy.pinch 1 e.lazy.pinch 1..2 e.lazy.pinch 1,2 It is basically equivalent to calling `to_a[index]`, but has the advantage of being a single invocation instead of two, and reads better. The #pinch method would be strictly a Lazy method and have no counterpart in Enumerable. -- http://bugs.ruby-lang.org/