From: "matz (Yukihiro Matsumoto)" Date: 2012-04-02T10:42:20+09:00 Subject: [ruby-core:44052] [ruby-trunk - Feature #6166] Enumerator::Lazy#pinch Issue #6166 has been updated by matz (Yukihiro Matsumoto). I am not sure what you mean by "does not act in place". Lazy sequence has position. Retrieving value from sequence moves its position, even calling to_a. So to make #pinch work as if "not acting in place", sequence needs to keep the values inside, everytime it generates. I don't want to do that since it hinders the best benefit from "lazy" sequence. Matz. ---------------------------------------- Feature #6166: Enumerator::Lazy#pinch https://bugs.ruby-lang.org/issues/6166#change-25582 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/