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

ruby-changes:32468

From: marcandre <ko1@a...>
Date: Fri, 10 Jan 2014 02:34:42 +0900 (JST)
Subject: [ruby-changes:32468] marcandRe: r44547 (trunk): * gc.c: Supplement object_id's rdoc for immediate and frozen string litterals

marcandre	2014-01-10 02:34:39 +0900 (Fri, 10 Jan 2014)

  New Revision: 44547

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

  Log:
    * gc.c: Supplement object_id's rdoc for immediate and frozen string litterals

  Modified files:
    trunk/gc.c
Index: gc.c
===================================================================
--- gc.c	(revision 44546)
+++ gc.c	(revision 44547)
@@ -2339,6 +2339,16 @@ id2ref(VALUE obj, VALUE objid) https://github.com/ruby/ruby/blob/trunk/gc.c#L2339
  *
  *  The same number will be returned on all calls to +object_id+ for a given object,
  *  and no two active objects will share an id.
+ *
+ *  Note that some objects of builtin classes are reused for optimization.
+ *  This is the case for immediate values and frozen string litterals.
+ *  Immediate values are not passed by reference by are passed by value:
+ *  +nil+, +true+, +false+, Fixnums. Some Floats may be immediates too.
+ *
+ *      Object.new.object_id  == Object.new.object_id  # => false
+ *      (21 * 2).object_id    == (21 * 2).object_id    # => true
+ *      "hello".object_id     == "hello".object_id     # => false
+ *      "hi".freeze.object_id == "hi".freeze.object_id # => true
  */
 
 /*

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

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