Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Object#instance_of?

obj.instance_of?(class) → true or false

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

Example
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