[#106341] [Ruby master Bug#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } — dorianmariefr <noreply@...>
Issue #18369 has been reported by dorianmariefr (Dorian Mari辿).
14 messages
2021/11/30
[#106351] [Ruby master Bug#18371] Release branches (release information in general) — "tenderlovemaking (Aaron Patterson)" <noreply@...>
Issue #18371 has been reported by tenderlovemaking (Aaron Patterson).
7 messages
2021/11/30
[ruby-core:106049] [Ruby master Bug#18334] ENV#to_h returns a new Hash object but Hash#to_h does not, which can cause inconsistencies
From:
"Eregon (Benoit Daloze)" <noreply@...>
Date:
2021-11-14 12:23:45 UTC
List:
ruby-core #106049
Issue #18334 has been updated by Eregon (Benoit Daloze).
I think it would be confusing if `ENV#dup` returns a `Hash` and not a `ENV`, as that would be inconsistent with all other `#dup`.
`to_SHORT` never guarantees to return a copy, so if you don't know the receiver and want to mutate it, you should probably use `obj.to_h.dup`, which already works fine.
----------------------------------------
Bug #18334: ENV#to_h returns a new Hash object but Hash#to_h does not, which can cause inconsistencies
https://bugs.ruby-lang.org/issues/18334#change-94636
* Author: postmodern (Hal Brodigan)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.0dev (2021-11-13T20:48:57Z master fc456adc6a) [x86_64-linux]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I noticed that in ruby-3.1.0-preview1 ENV#dup was removed in favor of ENV#to_h. However, methods that accept either ENV or a Hash object will not behave the same, since ENV#to_h returns a new Hash object but Hash#to_h returns the same Hash instance.
ENV.to_h.object_id
# => 14700
ENV.to_h.object_id
# => 14760
hash = {"FOO" => "bar"}
hash.to_h.object_id
# => 14820
hash.to_h.object_id
# => 14820
I propose that the ENV#dup method be re-added as `self.to_h.dup`.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>