From: Aaron Patterson Date: 2011-03-02T04:22:38+09:00 Subject: [ruby-core:35403] Why are hash keys sometimes duped? --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Why are some objects duped when they are used as hash keys and other objects are not? irb(main):001:0> list =3D %w{ hello } =3D> ["hello"] irb(main):002:0> str =3D "world" =3D> "world" irb(main):003:0> map =3D { list =3D> 1, str =3D> 2 } =3D> {["hello"]=3D>1, "world"=3D>2} irb(main):005:0> list << "world" =3D> ["hello", "world"] irb(main):006:0> map =3D> {["hello", "world"]=3D>1, "world"=3D>2} irb(main):007:0> str.replace("hi!") =3D> "hi!" irb(main):008:0> str =3D> "hi!" irb(main):009:0> map =3D> {["hello", "world"]=3D>1, "world"=3D>2} irb(main):010:0> RUBY_VERSION =3D> "1.9.3" irb(main):011:0> --=20 Aaron Patterson http://tenderlovemaking.com/ --opJtzjQTFsWo+cga Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJNbUeTAAoJEJUxcLy0/6/GTSAH/RAj8kBHq1oDMeTtYb3UfhfP GB8djkU2YSzbfGskNRoljpK3u1OdVQhCtyNauAGht/g6GuXAKXdqpystSm84JJs4 FO61z69FNdIlfbXoqDQsn7ZciexKsSrn6KCTgApSPycSpV3quJh6tdkw2x6uIP8m VFMLhaCon5m7DBSUeAx9u35LsatYE4SeTdhgUy8axKdy0MhrS9+520Y26vPADffP M+4ydw204yf6eTwhpEcNH2oGoMesIYuaLI7O5xZYwh8u8FQOeGtN/hr6TnwLBrn8 e7yC0ZcRkWHcjkYtmupflJwwwEf9tLgxgF2yMBcYX3ozsuDbFdTF/n/o8bJnvhI= =2EBS -----END PGP SIGNATURE----- --opJtzjQTFsWo+cga--