Skip to content

Instantly share code, notes, and snippets.

@zlx
Created July 18, 2012 14:09
Show Gist options
  • Save zlx/3136413 to your computer and use it in GitHub Desktop.
Save zlx/3136413 to your computer and use it in GitHub Desktop.
instance_of? and is_a?
# 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