# \[BUG\] Re: \[ruby-cvs:31600\] Ruby:r24382 (trunk): \* hash.c (rb\_hash\_replace): should copy compare\_by\_i

**URL:** <https://www.ruby-forum.com/t/bug-re-ruby-cvs-31600-ruby-r24382-trunk-hash-c-rb-hash-replace-should-copy-compare-by-i/173426>\
**Category:** Development\
**Created:** [August 8, 2009, 3:04pm UTC](https://www.ruby-forum.com/t/bug-re-ruby-cvs-31600-ruby-r24382-trunk-hash-c-rb-hash-replace-should-copy-compare-by-i/173426 "2009-08-08T15:04:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yugui\_SYuki\_S.S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/dec6dc/32.png) [@Yugui\_SYuki\_S.S](https://www.ruby-forum.com/u/Yugui_SYuki_S.S)\
**Post date:** [August 8, 2009, 3:04pm UTC](https://www.ruby-forum.com/t/bug-re-ruby-cvs-31600-ruby-r24382-trunk-hash-c-rb-hash-replace-should-copy-compare-by-i/173426/1 "2009-08-08T15:04:07Z")

</div>

Yuguie$B$G$9!#e(B

On 8/4/09 7:44 AM, removed\_email\_address@domain.invalid wrote:

> ```
> * hash.c (rb_hash_replace): should copy compare_by_identity status as well.
> [ruby-core:24728]
> 
> ```

e$B85$Ne(B[ruby-core:24728]e$B$N!"e(Bdup,  
clonee$B$Ge(Bcompare\_by\_identitye$B$,%3%T!\<$5$l$J$$e(B  
e$B$H$$$&LdBj$O$3$l$GD\>$j$^$7$?!#e(B

e$B$?$@!"$3$l$G$9$He(BHash#replacee$B$7$?\>l9g$^$G%3%T!\<$5$l$F$7$^$$$^$9$h$Me(B?  
Hash#replacee$B$Oe(B

> Replaces the contents of _hsh_ with  
> e$B$H=q$$$F$"$k$/$i$$$J$N$G!“FbMF$N$\_$r0$7$Fe(Bcompare\_by\_identity’nesse$B$O0$ie(B  
> e$B$J$$$H$$$&2r\<a$b$”$jF@$k$H;W$$$^$9!#e(B

e$B$I$A$i$bIT9,$K$J$k%1!\<%9$,$"$k$H;W$$$^$9$,!"$I$A$i$N5sF0$,K\>$^$7$$$G$7$ge(B  
e$B$&$+!#e(B

---

<div class="post-metadata">

**Author:** ![Yugui\_SYuki\_S.S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/dec6dc/32.png) [@Yugui\_SYuki\_S.S](https://www.ruby-forum.com/u/Yugui_SYuki_S.S)\
**Post date:** [August 8, 2009, 4:14pm UTC](https://www.ruby-forum.com/t/bug-re-ruby-cvs-31600-ruby-r24382-trunk-hash-c-rb-hash-replace-should-copy-compare-by-i/173426/2 "2009-08-08T16:14:21Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:39045] [BUG] Re: [ruby-cvs:31600] Ruby:r24382  
(trunk): \* hash.c (rb\_hash\_replace): should copy compare\_by\_identity  
status as well.”  
on Sat, 8 Aug 2009 22:03:00 +0900, “Yugui (Yuki S.)”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|e$B85$Ne(B[ruby-core:24728]e$B$N!“e(Bdup, clonee$B$Ge(Bcompare\_by\_identitye$B$,%3%T!\<$5$l$J$$e(B  
|e$B$H$$$&LdBj$O$3$l$GD\>$j$^$7$?!#e(B  
|  
|e$B$?$@!”$3$l$G$9$He(BHash#replacee$B$7$?\>l9g$^$G%3%T!\<$5$l$F$7$^$$$^$9$h$Me(B?  
|Hash#replacee$B$Oe(B  
|\> Replaces the contents of _hsh_ with  
|e$B$H=q$$$F$“$k$/$i$$$J$N$G!“FbMF$N$\_$r0$7$Fe(Bcompare\_by\_identity’nesse$B$O0$ie(B  
|e$B$J$$$H$$$&2r\<a$b$”$jF@$k$H;W$$$^$9!#e(B  
|  
|e$B$I$A$i$bIT9,$K$J$k%1!\<%9$,$”$k$H;W$$$^$9$,!"$I$A$i$N5sF0$,K\>$^$7$$$G$7$ge(B  
|e$B$&$+!#e(B

e$B$“$^$jH/@8$7$J$$$H;W$&$N$G!”?4G[$7$F$b$7$+$?$,$J$$$h$&$J5$$be(B  
e$B$7$J$$$G$b$J$$$N$G$9$,!“;EMM$H$7$F$ODj5A$9$kI,MW$,$”$k$G$7$ge(B  
e$B$&$M!#e(B

e$B$G!";d$N9M$($r8@$($P!"e(BHashe$B$N%-!\<$OHf3S$N\>uBV$H$NAH$\_9g$o$;$Ge(B  
e$B$J$$$H0UL#$,$J$$$h$&$K;W$$$^$9!#$?$H$($P!"e(B

h = {}  
h.compare\_by\_identity  
h[“foo”] = “bar”  
h[“foo”] = “baz”  
p h # =\> {“foo”=\>“bar”, “foo”=\>“baz”}

e$B$H$J$k$o$1$G$9$,!"2\>$Ke(Breplacee$B$,e(Bcompare\_by\_identitye$B\>uBV$r%3%T!\<e(B  
e$B$7$J$$$H$9$k$He(B

h2 = {}  
h2.replace(h)  
p h2[“foo”] # =\> “bar”? “baz”? e$BM=B,:$Fqe(B

e$B$H$J$k$o$1$G$9!#$3$l$O$“$s$^$j$&$l$7$/$”$j$^$;$se(B(1.9e$B$@$+$iA^e(B  
e$BF~=g$,Aa$$J}$,M%@h$J$s$G$9$,!“$$$D$bA^F~=g$,L@$i$+$H$O8B$j$^e(B  
e$B$;$s$7e(B)e$B!#0lJ}!”%3%T!\<$9$k$J$i$Pe(B

p h2 # =\> {“foo”=\>“bar”, “foo”=\>“baz”}

e$B$H$J$k$G$7$g$&!#e(Bh2[“foo”]e$B$N7k2L$OEvA3e(Bnile$B$G$9!#e(B

e$B$H$$$&$o$1$G!“8=\>uDL$je(Bcompare\_by\_identitye$B@-$Oe(Breplacee$B$K$h$C$Fe(B  
e$B%3%T!\<$5$l$?J}$,$h$$!”$K0lI\<$G$9!#e(B

```
                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

```
