Project

General

Profile

Actions

Feature #13657

closed

Simplify usage of Enumerable#reject

Added by JustJosh (Joshua Stowers) almost 7 years ago. Updated almost 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:81673]

Description

The reject method is more complicated than it has to be when removing only a specific value.
It would be convenient if we could just plug in the value we wish to delete as an optional argument, for example:

[1, 2, 3, 4].reject(3) # => [1, 2, 4]

as apposed to:

[1, 2, 3, 4].reject { |element| element == 3 } # => [1, 2, 4]

The next best method I can think of is #delete, but that returns the value which is deleted.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0