ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: stowers.joshua@live.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:81724] [Ruby trunk Feature#13657] Simplify usage of Enumerable#reject
Date: Mon, 19 Jun 2017 15:28:02 +0000	[thread overview]
Message-ID: <redmine.journal-65425.20170619152801.3cdb7e3c03e3f2cb@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13657.20170614024019@ruby-lang.org

Issue #13657 has been updated by JustJosh (Joshua Stowers).


Great! You're right, that will accomplish this _exactly_.

Do you see any hope in adding this functionality to `#reject` regardless of the existence of `#grep_v`?
This other method is difficult to make sense of unless the developers are either familiar with it already or have used `grep` extensively enough to recognize its purpose.

Adding the functionality would also reduce the number of methods developer's have to know.
Also it wouldn't hurt to have.

Thanks for pointing out the existence of `#grep_v`

----------------------------------------
Feature #13657: Simplify usage of Enumerable#reject
https://bugs.ruby-lang.org/issues/13657#change-65425

* Author: JustJosh (Joshua Stowers)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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:

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

as apposed to:

~~~ ruby
[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.




-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2017-06-19 15:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-13657.20170614024019@ruby-lang.org>
2017-06-14  2:40 ` [ruby-core:81673] [Ruby trunk Feature#13657] Simplify usage of Enumerable#reject stowers.joshua
2017-06-14  2:51 ` [ruby-core:81675] [Ruby trunk Feature#13657][Rejected] " shyouhei
2017-06-19 15:28 ` stowers.joshua [this message]
2017-06-19 22:46 ` [ruby-core:81728] [Ruby trunk Feature#13657] " shyouhei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-65425.20170619152801.3cdb7e3c03e3f2cb@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).