public Method

Object.instance_of?(p1)

obj.instance_of?(class)     true or false

Returns true if obj is an instance of the given class. See also Object#kind_of?.

Source Code

/*
*  call-seq:
*     obj.instance_of?(class)    => true or false
*  
*  Returns <code>true</code> if <i>obj</i> is an instance of the given
*  class. See also <code>Object#kind_of?</code>.
*/

VALUE
rb_obj_is_instance_of(obj, c)
   VALUE obj, c;
{
   switch (TYPE(c)) {
     case T_MODULE:
     case T_CLASS:
     case T_ICLASS:
       break;
     default:
       rb_raise(rb_eTypeError, "class or module required");
   }

   if (rb_obj_class(obj) == c) return Qtrue;
   return Qfalse;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.