Feature #7068

ability to deactivate Hash#compare_by_identity()

Added by Suraj Kurapati over 1 year ago. Updated 2 months ago.

[ruby-core:47697]
Status:Rejected
Priority:Low
Assignee:Yukihiro Matsumoto
Category:-
Target version:next minor

Description

Hello,

I am using ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux].

There is no way to deactivate a Hash's compare by identity behavior:

h = Hash.new
h.comparebyidentity
h.comparebyidentity? #=> true
h.comparebyidentity
h.comparebyidentity? #=> still true

I want the ability to deactivate that behavior afterwards, like this:

h.comparebyidentity = false

Thanks for your consideration.

History

#1 Updated by Eric Hodel over 1 year ago

  • Status changed from Open to Feedback

=begin

h = {}
h.comparebyidentity = true
h['a'] = 1
h['a'] = 2
h.comparebyidentity = false

What value is returned for (({h['a']}))?
=end

#2 Updated by Yusuke Endoh over 1 year ago

  • Assignee set to Yukihiro Matsumoto
  • Priority changed from Normal to Low
  • Target version set to next minor

Please make the proposal complete: your use case and the corner case behavior (Eric said).

Yusuke Endoh mame@tsg.ne.jp

#3 Updated by Suraj Kurapati 2 months ago

Eric Hodel wrote:

=begin

h = {}
h.comparebyidentity = true
h['a'] = 1
h['a'] = 2
h.comparebyidentity = false

What value is returned for (({h['a']}))?
=end

Good point. This feature would violate the invariant of hash keys being unique. You may reject this feature request. Thanks.

#4 Updated by Benoit Daloze 2 months ago

  • Status changed from Feedback to Rejected

Also available in: Atom PDF