fork download
  1. class Foo; end
  2. class A < Foo; end
  3. class B; end
  4.  
  5. def tst(x)
  6. if x.class == Foo then puts "Same type."
  7. elsif x.is_a?(Foo) then puts "Extends type."
  8. else puts "Not related."
  9. end
  10. end
  11.  
  12. tst(Foo.new)
  13. tst(A.new)
  14. tst(B.new)
Success #stdin #stdout 0.01s 6364KB
stdin
Standard input is empty
stdout
Same type.
Extends type.
Not related.