Project

General

Profile

Actions

Feature #6166

closed

Enumerator::Lazy#pinch

Added by trans (Thomas Sawyer) about 12 years ago. Updated about 12 years ago.

Status:
Rejected
Target version:
-
[ruby-core:43370]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0