Project

General

Profile

Actions

Bug #1871

closed

Hash#compare_by_identity Does Not Persist Over #dup or #clone

Added by runpaint (Run Paint Run Run) almost 15 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-08-03 trunk 24372) [i686-linux]
Backport:
[ruby-core:24728]

Description

=begin
The "ident"ness of a Hash doesn't persist over #dup or #clone which makes those methods destructive when they rehash. Given that normally hash == hash.dup, and that default procs are retained over these two operations, I assume this is a bug.

h = {'foo' => 'bar'}
h.compare_by_identity
h['foo'] = 'glark'

p h #=> {"foo"=>"bar", "foo"=>"glark"}
p h.compare_by_identity? #=> true

j = h.dup
p j #=> {"foo"=>"glark"}
p j.compare_by_identity? #=> false

k = h.clone
p k #=> {"foo"=>"glark"}
p k.compare_by_identity? #=> false
=end

Actions #1

Updated by matz (Yukihiro Matsumoto) almost 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r24382.
=end

Actions

Also available in: Atom PDF

Like0
Like0