From: shevegen@... Date: 2019-11-04T21:35:48+00:00 Subject: [ruby-core:95681] [Ruby master Feature#15323] [PATCH] Proposal: Add Enumerable#filter_map Issue #15323 has been updated by shevegen (Robert A. Heiler). Actually, after rereading what Jonathan wrote, he referred not to "true" values per se, but as to whether "non nil values" are to be included. So perhaps I misunderstood his comment. I think that filter still applies to the .select and should return what matches to the given criterium, so from this point of view I understand Jonathan's confusion. Either way I think it is best to define this clearly. ---------------------------------------- Feature #15323: [PATCH] Proposal: Add Enumerable#filter_map https://bugs.ruby-lang.org/issues/15323#change-82468 * Author: alfonsojimenez (Alfonso Jim�nez) * Status: Closed * 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] ~~~ 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: