Actions
Bug #17767
closed`Cloned ENV` inconsistently returns `ENV` or `self`
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
Description
GH-PR: https://github.com/ruby/ruby/pull/4344
Is this an expected behavior? 😅
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
cloned_env = ENV.clone
p ENV.each_key{}.equal?(ENV) #=> true
p cloned_env.each_key{}.equal?(cloned_env) #=> true
ENV.delete('TEST')
err = ENV.fetch('TEST') rescue $!
p err.receiver.equal?(ENV) #=> true
err = cloned_env.fetch('TEST') rescue $!
p err.receiver.equal?(cloned_env) #=> false
ENV['TEST'] = 'TRUE'
p ENV.select!{ false }.equal?(ENV) #=> true
cloned_env['TEST'] = 'TRUE'
p cloned_env.select!{ false }.equal?(cloned_env) #=> false
I guess ruby don't care Cloned ENV
objects.
Yes, anyone basically do not write these code.
But the behaviors looks weird to me. 😓
Should block to clone?
Should return ENV?
Should return self?
I think they return self
makes consistently behaviors and does not break compatibilities.
So I have created this PR 😅
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0