Created
July 18, 2012 14:09
-
-
Save zlx/3136413 to your computer and use it in GitHub Desktop.
instance_of? and is_a?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test is_a? and instance_of? methods | |
# instance_of? ignore the superclass | |
class SuperClass; end | |
class ChildClass < SuperClass ; end | |
b = ChildClass.new | |
puts b, b.instance_of?(SuperClass), b.is_a?(SuperClass) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment