From 7c5dc219d093fc6909244005514029c02b540ae6 Mon Sep 17 00:00:00 2001 From: zzak Date: Wed, 14 Aug 2013 17:34:40 +0000 Subject: [PATCH] * hash.c (rb_hash_aset): [DOC] Document key dup patch by @kachick [Fixes GH-382] https://github.com/ruby/ruby/pull/382 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ hash.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index fbf727fe06..4c8e2194fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Aug 15 02:32:40 2013 Zachary Scott + + * hash.c (rb_hash_aset): [DOC] Document key dup patch by @kachick + [Fixes GH-382] https://github.com/ruby/ruby/pull/382 + Wed Aug 14 14:28:39 2013 NAKAMURA Usaku * proc.c (rb_mod_define_method): now they return the symbols of the diff --git a/hash.c b/hash.c index 91a4e9fea0..8de71db268 100644 --- a/hash.c +++ b/hash.c @@ -1261,17 +1261,24 @@ static NOINSERT_UPDATE_CALLBACK(hash_aset_str) * hsh[key] = value -> value * hsh.store(key, value) -> value * - * Element Assignment---Associates the value given by - * value with the key given by key. - * key should not have its value changed while it is in - * use as a key (a String passed as a key will be - * duplicated and frozen). + * == Element Assignment + * + * Associates the value given by +value+ with the key given by +key+. * * h = { "a" => 100, "b" => 200 } * h["a"] = 9 * h["c"] = 4 * h #=> {"a"=>9, "b"=>200, "c"=>4} * + * +key+ should not have its value changed while it is in use as a key (an + * unfrozen String passed as a key will be duplicated and frozen). + * + * a = "a" + * b = "b".freeze + * h = { a => 100, b => 200 } + * h.key(100).equal? a #=> false + * h.key(200).equal? b #=> true + * */ VALUE