Project

General

Profile

Actions

Feature #14197

open

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

Added by znz (Kazuhiro NISHIYAMA) almost 7 years ago. Updated over 4 years ago.

Status:
Open
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 1 (0 open1 closed)

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0