From 32e6600128a073821b80aaf8ab40561e694f7733 Mon Sep 17 00:00:00 2001 From: ayumin Date: Wed, 11 Jan 2012 17:19:54 +0000 Subject: [PATCH] * 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 --- ChangeLog | 6 ++++++ object.c | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f702895c3..b686759bdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Jan 12 02:14:43 2012 Ayumu AIZAWA + + * object.c: Added examples for Object#is_a? and + Object#instance_of? patcheed from Manoj Kumar. + [Bug #5880] [ruby-core:42057] + Thu Jan 12 00:57:48 2012 Kazuhiro NISHIYAMA * lib/mkmf.rb: verbose-mode can use by RM, RMDIRS, etc. 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 true if obj is an instance of the given * class. See also Object#kind_of?. + * + * 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