Project

General

Profile

Feature #15323

Updated by alfonsojimenez (Alfonso Jiménez) about 6 years ago

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 


  



 

Back