From: keystonelemur@... Date: 2021-02-10T07:56:14+00:00 Subject: [ruby-core:102436] [Ruby master Feature#17140] Merge Enumerable#grep(_v) with Enumerable#select/reject Issue #17140 has been updated by baweaver (Brandon Weaver). Would this feature still be of interest? ---------------------------------------- Feature #17140: Merge Enumerable#grep(_v) with Enumerable#select/reject https://bugs.ruby-lang.org/issues/17140#change-90320 * Author: baweaver (Brandon Weaver) * Status: Open * Priority: Normal ---------------------------------------- In recent versions of Ruby we've gotten new behavior of some Enumerable methods like any?, all?, none?, one?, and others to support a single argument pattern that responds to `===`. This is very powerful, and very useful. Currently Enumerable has `grep` and `grep_v` which allow this as a way to filter lists. These names require some understanding of Unix to be familiar with, but naming aside, I feel it may make sense to implement `===` pattern arguments in `Enumerable#select` and `Enumerable#reject` as with the above. Proposed Syntax: ```ruby list_of_numbers.select(1..10) words.reject({ 'and', 'the', 'of' }) ``` I believe this would help with readability and would simplify syntax options by unifying on this standard. My concern is that `Enumerable#find` already takes a single argument, `ifnone`, and may not be able to implement this behavior. I would be curious to see how many use `ifnone` but feel this would be more critically breaking to do. -- https://bugs.ruby-lang.org/ Unsubscribe: