kind_of?

obj.kind_of?(class) â true or false
Instance Public methods

Returns true if class is the class of obj, or if class is one of the superclasses of obj or modules included in obj.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module M;    end
class A
  include M
end
class B < A; end
class C < B; end
 
b = B.new
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
b.kind_of? M       #=> true
doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.