Created
August 25, 2011 12:59
-
-
Save rodrigoflores/1170593 to your computer and use it in GitHub Desktop.
Case where with classes
This file contains hidden or 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
case my_var | |
when String then puts "It is a string" | |
when Integer then puts "It is an integer" | |
else puts "It is another thing" | |
end | |
#instead of | |
case my_var.class | |
when String then puts "It is a string" | |
when Integer then puts "It is an integer" | |
else puts "It is another thing" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment