Actions
Feature #18334
openENV#to_h returns a new Hash object but Hash#to_h does not, which can cause inconsistencies
Status:
Open
Assignee:
-
Target version:
-
Description
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
.
Actions
Like0
Like0Like0Like0