Project

General

Profile

Actions

Feature #7068

closed

ability to deactivate Hash#compare_by_identity()

Feature #7068: ability to deactivate Hash#compare_by_identity()

Added by sunaku (Suraj Kurapati) about 13 years ago. Updated over 11 years ago.

Status:
Rejected
Target version:
[ruby-core:47697]

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.compare_by_identity
h.compare_by_identity? #=> true
h.compare_by_identity
h.compare_by_identity? #=> still true

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

h.compare_by_identity = false

Thanks for your consideration.

Updated by drbrain (Eric Hodel) about 13 years ago Actions #1 [ruby-core:47949]

  • Status changed from Open to Feedback

=begin

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

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

Updated by mame (Yusuke Endoh) almost 13 years ago Actions #2 [ruby-core:49916]

  • Assignee set to matz (Yukihiro Matsumoto)
  • Priority changed from Normal to 3
  • Target version set to 2.6

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

--
Yusuke Endoh

Updated by sunaku (Suraj Kurapati) over 11 years ago Actions #3 [ruby-core:60569]

Eric Hodel wrote:

=begin

h = {}
h.compare_by_identity = true
h['a'] = 1
h['a'] = 2
h.compare_by_identity = 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.

Updated by Eregon (Benoit Daloze) over 11 years ago Actions #4 [ruby-core:60575]

  • Status changed from Feedback to Rejected
Actions

Also available in: PDF Atom