Issue #13784 has been updated by davidarnold (David Arnold).


> No, please fix your bug. Your proposal and its title are explicitly to make filter an alias of select.

Not sure why this would be "my" bug to fix, I didn't have anything to do with the code that was written 10 years ago :)  Also, my proposal is explicitly to make filter an alias of select *on Enumerable* -- check the title.

I do agree that the inconsistency is bad in Hash and would like to see it solved too, but I was a little worried that reaching out and changing Hash behavior would increase the risk that this feature request would be rejected.  I think it's really important to get filter into Enumerable and wouldn't want to see it quashed by concerns around changing Hash.

----------------------------------------
Feature #13784: Add Enumerable#filter as an alias of Enumerable#select
https://bugs.ruby-lang.org/issues/13784#change-66104

* Author: davidarnold (David Arnold)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Ruby has a full set of functional tools in the Enumerable module under the "-ect" methods (viz. collect, select, inject).  However the usual industry terms for these are map, filter, and reduce.

For example, Swift, Python, and ECMAScript all use the names map, filter, and reduce to describe these methods.  Also, this language independent MIT course uses map, filter and reduce: http://web.mit.edu/6.005/www/fa15/classes/25-map-filter-reduce/

Ruby has aliases for map and reduce, but filter is noticeably absent.  This feature request is simply to add an alias to Enumerable for filter.  This will ease the transition of developers from other languages to Ruby.

Desired behavior:

[:foo, :bar].filter { |x| x == :foo } # => [:foo]

Current behavior:

[:foo, :bar].filter { |x| x == :foo } # NoMethodError: undefined method `filter'



-- 
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>