Project

General

Profile

Actions

Feature #15323

closed

[PATCH] Proposal: Add Enumerable#filter_map

Added by alfonsojimenez (Alfonso Jiménez) about 6 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:89907]

Description

This is a proposal for a combined filter + map method (https://bugs.ruby-lang.org/issues/5663).

This method both filters and maps the elements of an enumerable in just one iteration:

(1..10).filter_map { |i| i * 2 if i.even? } #=> [4, 8, 12, 16, 20]

GitHub PR: https://github.com/ruby/ruby/pull/2017


Files

0001-Adding-Enumerable-filter_map.patch (4.61 KB) 0001-Adding-Enumerable-filter_map.patch alfonsojimenez (Alfonso Jiménez), 04/25/2019 09:49 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #5663: Combined map/select methodClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0