[前][次][番号順一覧][スレッド一覧]

ruby-changes:30476

From: zzak <ko1@a...>
Date: Thu, 15 Aug 2013 02:34:48 +0900 (JST)
Subject: [ruby-changes:30476] zzak:r42555 (trunk): * hash.c (rb_hash_aset): [DOC] Document key dup patch by @kachick

zzak	2013-08-15 02:34:40 +0900 (Thu, 15 Aug 2013)

  New Revision: 42555

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42555

  Log:
    * hash.c (rb_hash_aset): [DOC] Document key dup patch by @kachick
      [Fixes GH-382] https://github.com/ruby/ruby/pull/382

  Modified files:
    trunk/ChangeLog
    trunk/hash.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42554)
+++ ChangeLog	(revision 42555)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Aug 15 02:32:40 2013  Zachary Scott  <e@z...>
+
+	* 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  <usa@r...>
 
 	* proc.c (rb_mod_define_method): now they return the symbols of the
Index: hash.c
===================================================================
--- hash.c	(revision 42554)
+++ hash.c	(revision 42555)
@@ -1261,17 +1261,24 @@ static NOINSERT_UPDATE_CALLBACK(hash_ase https://github.com/ruby/ruby/blob/trunk/hash.c#L1261
  *     hsh[key] = value        -> value
  *     hsh.store(key, value)   -> value
  *
- *  Element Assignment---Associates the value given by
- *  <i>value</i> with the key given by <i>key</i>.
- *  <i>key</i> should not have its value changed while it is in
- *  use as a key (a <code>String</code> 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
+ *  <tt>unfrozen String</tt> 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]