summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-11 17:19:54 +0000
committerayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-11 17:19:54 +0000
commit32e6600128a073821b80aaf8ab40561e694f7733 (patch)
tree8eac4ec763e019a5dbebb631704d03c564f738a5 /object.c
parentc6fb7c1c877c64e62b9239ca6ce114e6e508b9cc (diff)
downloadruby-32e6600128a073821b80aaf8ab40561e694f7733.tar.gz
* object.c: Added examples for Object#is_a? and Object#instance_of?
patcheed from Manoj Kumar. [Bug #5880] [ruby-core:42057] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/object.c b/object.c
index 24d85d428b..09b3999231 100644
--- a/object.c
+++ b/object.c
@@ -490,6 +490,15 @@ rb_obj_inspect(VALUE obj)
*
* Returns <code>true</code> if <i>obj</i> is an instance of the given
* class. See also <code>Object#kind_of?</code>.
+ *
+ * class A; end
+ * class B < A; end
+ * class C < B; end
+ *
+ * b = B.new
+ * b.instance_of? A #=> false
+ * b.instance_of? B #=> true
+ * b.instance_of? C #=> false
*/
VALUE
@@ -524,11 +533,13 @@ rb_obj_is_instance_of(VALUE obj, VALUE c)
* end
* class B < A; end
* class C < B; end
+ *
* b = B.new
- * b.instance_of? A #=> false
- * b.instance_of? B #=> true
- * b.instance_of? C #=> false
- * b.instance_of? M #=> false
+ * b.is_a? A #=> true
+ * b.is_a? B #=> true
+ * b.is_a? C #=> false
+ * b.is_a? M #=> true
+ *
* b.kind_of? A #=> true
* b.kind_of? B #=> true
* b.kind_of? C #=> false