[ruby-core:89907] [Ruby trunk Feature#15323] [PATCH] Proposal: Add Enumerable#filter_map

From: me@...
Date: 2018-11-20 11:59:45 UTC
List: ruby-core #89907
Issue #15323 has been reported by alfonsojimenez (Alfonso Jim辿nez).

----------------------------------------
Feature #15323: [PATCH] Proposal: Add Enumerable#filter_map
https://bugs.ruby-lang.org/issues/15323

* Author: alfonsojimenez (Alfonso Jim辿nez)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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:

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



 

---Files--------------------------------
0001-Adding-Enumerable-filter_map.patch (4.55 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next