Project

General

Profile

Feature #14197

`Enumerable#{select,reject}` accept a pattern argument

Added by znz (Kazuhiro NISHIYAMA) almost 3 years ago. Updated 7 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:84333]

Description

#all?, #any?, #none?, and #one? accept pattern arguments since 2.5.0.

#grep, and #grep_v have such feature, but it is hard for me to remember them since I would be thinking of using #select, or #reject, and #select and #reject don't have such feature.

I want to write

collection.reject(/re/)

instead of

collection.reject {|item| /re/ =~ item }

or

collection.grep_v(/re/)

Related issues

Related to Ruby master - Feature #11286: [PATCH] Add case equality arity to Enumerable's sequence predicates.Closedmatz (Yukihiro Matsumoto)Actions

Also available in: Atom PDF