Created
October 29, 2012 15:42
-
-
Save bsimpson/3974262 to your computer and use it in GitHub Desktop.
Case on 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 Foo | |
end | |
def test_class(foo) | |
case foo.class | |
when Foo | |
puts "foo" | |
else | |
puts "other" | |
end | |
end | |
foo = Foo.new | |
test_class(foo) # => "other" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment