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

ruby-changes:22228

From: ayumin <ko1@a...>
Date: Thu, 12 Jan 2012 02:20:19 +0900 (JST)
Subject: [ruby-changes:22228] ayumin:r34277 (trunk): * object.c: Added examples for Object#is_a? and Object#instance_of?

ayumin	2012-01-12 02:19:54 +0900 (Thu, 12 Jan 2012)

  New Revision: 34277

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

  Log:
    * object.c: Added examples for Object#is_a? and Object#instance_of?
      patcheed from Manoj Kumar. [Bug #5880] [ruby-core:42057]

  Modified files:
    trunk/ChangeLog
    trunk/object.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34276)
+++ ChangeLog	(revision 34277)
@@ -1,3 +1,9 @@
+Thu Jan 12 02:14:43 2012  Ayumu AIZAWA  <ayumu.aizawa@g...>
+
+	* 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  <zn@m...>
 
 	* lib/mkmf.rb: verbose-mode can use by RM, RMDIRS, etc.
Index: object.c
===================================================================
--- object.c	(revision 34276)
+++ object.c	(revision 34277)
@@ -490,6 +490,15 @@
  *
  *  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 @@
  *     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

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

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