ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "naruse (Yui NARUSE)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:106430] [Ruby master Bug#16908] Strange behaviour of Hash#shift when used with `default_proc`.
Date: Fri, 03 Dec 2021 02:23:14 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-95072.20211203022313.3344@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16908.20200523021553.3344@ruby-lang.org

Issue #16908 has been updated by naruse (Yui NARUSE).


ioquatix (Samuel Williams) wrote in #note-8:
> Should we introduce some kind of deprecation or warning in 3.1?

Not allowed.
Ruby 3.1 shouldn't introduce anything which requests application developers to change something in their application code.
Deprecation warning is just a way of communications to request application developers to fix their application code.

----------------------------------------
Bug #16908: Strange behaviour of Hash#shift when used with `default_proc`.
https://bugs.ruby-lang.org/issues/16908#change-95072

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* ruby -v: 2.7.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I don't have any strong opinion about this, but I observed the following behaviour which I thought was confusing. Maybe it's okay, or maybe we should change it to be more consistent.

```
hash = Hash.new{|k,v| k[v] = 0}

hash.shift # => 0
hash.shift # => [nil, 0]
```

My feeling was, both cases should return `[nil, 0]`.




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

  parent reply	other threads:[~2021-12-03  2:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-23  2:15 [ruby-core:98486] [Ruby master Bug#16908] Strange behaviour of Hash#shift when used with `default_proc` samuel
2020-05-23  2:26 ` [ruby-core:98487] " merch-redmine
2020-05-23  2:38 ` [ruby-core:98488] " samuel
2020-05-23  2:53 ` [ruby-core:98489] " merch-redmine
2020-05-23 12:37 ` [ruby-core:98491] " eregontp
2020-05-23 12:39 ` [ruby-core:98492] " eregontp
2020-05-24  0:53 ` [ruby-core:98493] " daniel
2021-03-17  5:31 ` [ruby-core:102900] " matz
2021-09-27  5:37 ` [ruby-core:105439] " ioquatix (Samuel Williams)
2021-12-03  2:23 ` naruse (Yui NARUSE) [this message]
2021-12-27 22:46 ` [ruby-core:106855] " jeremyevans0 (Jeremy Evans)
2022-01-01  7:12 ` [ruby-core:106938] " ioquatix (Samuel Williams)
2022-01-14  3:01 ` [ruby-core:107113] " mame (Yusuke Endoh)
2022-01-15  1:39 ` [ruby-core:107135] " ioquatix (Samuel Williams)

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-95072.20211203022313.3344@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).