Created
April 4, 2012 21:47
-
-
Save xpepper/2305942 to your computer and use it in GitHub Desktop.
How do you tell if a Ruby object is a class?
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
class Object | |
def is_a_class? | |
respond_to? :superclass | |
end | |
end | |
class MyClass | |
end | |
puts "hi there!".is_a_class? # => false | |
puts MyClass.is_a_class? # => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment