[ruby-core:96005] [Ruby master Feature#15323] [PATCH] Proposal: Add Enumerable#filter_map
From:
nobu@...
Date:
2019-11-28 04:19:50 UTC
List:
ruby-core #96005
Issue #15323 has been updated by nobu (Nobuyoshi Nakada).
It seems OK as the original proposal is same as the current behavior.
----------------------------------------
Feature #15323: [PATCH] Proposal: Add Enumerable#filter_map
https://bugs.ruby-lang.org/issues/15323#change-82841
* Author: alfonsojimenez (Alfonso Jim=E9nez)
* Status: Closed
* Priority: Normal
* Assignee: =
* Target version: =
----------------------------------------
This is a proposal for a combined `filter` + `map` method (https://bugs.rub=
y-lang.org/issues/5663).
This method both filters and maps the elements of an enumerable in just one=
iteration:
~~~ ruby
(1..10).filter_map { |i| i * 2 if i.even? } #=3D> [4, 8, 12, 16, 20]
~~~
GitHub PR: https://github.com/ruby/ruby/pull/2017
=
---Files--------------------------------
0001-Adding-Enumerable-filter_map.patch (4.61 KB)
-- =
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>