irb
module ParentModule; end
module ChildModule; end
class ParentClass
include ParentModule
end
class ChildClass < ParentClass
include ChildModule
end
child_instance = ChildClass.new
child_instance.is_a? ChildClass #=> true
child_instance.is_a? ParentClass #=> true
child_instance.is_a? Object #=> true
child_instance.is_a? String #=> false
child_instance.is_a? ParentModule #=> true
child_instance.is_a? ChildModule #=> true
--Une instance directe de la classe, ou
child_instance.instance_of? ChildClass #=> true
child_instance.instance_of? ParentClass #=> false
child_instance.instance_of? Object #=> false
child_instance.instance_of? String #=> false
child_instance.instance_of? ParentModule #=> false
child_instance.instance_of? ChildModule #=> false
Recommended Posts