From: nagachika00@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:103454] [Ruby master Bug#17735] `Hash#transform_keys!` drops non evaluated keys
Date: Thu, 15 Apr 2021 01:29:49 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-91549.20210415012948.4551@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17735.20210320063314.4551@ruby-lang.org
Issue #17735 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 2.5: UNKNOWN, 2.6: REQUIRED, 2.7: REQUIRED, 3.0: REQUIRED to 2.5: UNKNOWN, 2.6: REQUIRED, 2.7: REQUIRED, 3.0: DONE
ruby_3_0 84d9a9afc0b49d095541acb9832f8b12fb506e19 merged revision(s) 31e0382723bfb35cffe3ca485dd0577668cafa07,5e5fb72f99701dc27c66ab148471893f14e6d6f0,fb6ebe55d91187d9635e0183d47dbf38e95b1141,522d4cd32f7727886f4fcbc28ed29c08d361ee20.
----------------------------------------
Bug #17735: `Hash#transform_keys!` drops non evaluated keys
https://bugs.ruby-lang.org/issues/17735#change-91549
* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
* Backport: 2.5: UNKNOWN, 2.6: REQUIRED, 2.7: REQUIRED, 3.0: DONE
----------------------------------------
```ruby
hash = {a: 1, b: 2, c: 3}
hash.transform_values!(){ raise } rescue
p hash #=> {:a=>1, :b=>2, :c=>3}
```
```ruby
hash = {a: 1, b: 2, c: 3}
hash.transform_keys!(){ raise } rescue
p hash #=> {}
```
Is this an intentional behavior?
I expected behavior like `transform_values!` in `transform_keys!` (Keeping non evaluated key-value pairs when exiting the block).
PR: https://github.com/ruby/ruby/pull/4294
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2021-04-15 1:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-20 6:33 [ruby-core:102949] [Ruby master Bug#17735] `Hash#transform_keys!` drops non evaluated keys kachick1
2021-03-20 8:52 ` [ruby-core:102960] " nobu
2021-03-28 9:55 ` [ruby-core:103070] " nagachika00
2021-04-15 1:29 ` nagachika00 [this message]
2021-09-14 10:24 ` [ruby-core:105249] " nagachika (Tomoyuki Chikanaga)
2021-09-18 7:51 ` [ruby-core:105337] " nagachika (Tomoyuki Chikanaga)
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-91549.20210415012948.4551@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).