From: "trans (Thomas Sawyer)" Date: 2012-04-01T02:48:32+09:00 Subject: [ruby-core:44018] [ruby-trunk - Feature #6166] Enumerator::Lazy#pinch Issue #6166 has been updated by trans (Thomas Sawyer). Also are you sure #first should be non-lazy? e.g. max_records = 1000000 recs = records.first(max_records) recs.pinch(@page_no, 25).each do |page_recs| ... end Hmm... maybe #page is better name then #pinch? In any case, the point is I think every enumeration method than can be lazy should be lazy, and a special method that's not an enumerable method should allows us to extract subsets. That method (whether called pinch or something else) would be the most flexible and optimized since it is designed to very task of de-lazying and extraction. ---------------------------------------- Feature #6166: Enumerator::Lazy#pinch https://bugs.ruby-lang.org/issues/6166#change-25546 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/