summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-09 17:34:39 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-09 17:34:39 +0000
commit705f9a7e809d47fa7e4e94196c2ffd1e5a74dd1e (patch)
tree1985242d90a9892e06e01ebf2f11fb4be5db5786
parentcc366241ce89ee2397b9c203b5798b9f197a293d (diff)
* gc.c: Supplement object_id's rdoc for immediate and frozen string litterals
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--gc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index d33a6fde51e..262dfe7d049 100644
--- a/gc.c
+++ b/gc.c
@@ -2339,6 +2339,16 @@ id2ref(VALUE obj, VALUE objid)
*
* 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
*/
/*