ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "sawa (Tsuyoshi Sawada)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110734] [Ruby master Feature#19128] Hash#delete could take a second argument as the default value?
Date: Sun, 13 Nov 2022 02:30:56 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-100069.20221113023055.48480@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19128.20221112161018.48480@ruby-lang.org

Issue #19128 has been updated by sawa (Tsuyoshi Sawada).


Since you are avoiding doing:

```rb
{}.delete(:a) || []
```

it must be the case that you have a hash in which `nil` can be a meaningful value, and you want to distinguish that from the case where `delete` results in a miss hit. What is the use case for that?

----------------------------------------
Feature #19128: Hash#delete could take a second argument as the default value?
https://bugs.ruby-lang.org/issues/19128#change-100069

* Author: dorianmariefr (Dorian Marié)
* Status: Open
* Priority: Normal
----------------------------------------
e.g. `{}.delete(:a, [])` would return `[]`



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

  reply	other threads:[~2022-11-13  2:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 16:10 [ruby-core:110725] [Ruby master Feature#19128] Hash#delete could take a second argument as the default value? dorianmariefr
2022-11-13  2:30 ` sawa (Tsuyoshi Sawada) [this message]
2022-11-14 10:26 ` [ruby-core:110751] " nobu (Nobuyoshi Nakada)
2022-11-14 12:03 ` [ruby-core:110753] " byroot (Jean Boussier)
2022-11-24  9:16 ` [ruby-core:110872] " dorianmariefr

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-100069.20221113023055.48480@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=ruby-core@neon.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).