Created
March 10, 2012 19:30
-
-
Save wrburgess/2012625 to your computer and use it in GitHub Desktop.
ruby case/when example #ruby #example #logic #structure #case
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
variable = 'something' | |
case variable | |
when some_string.match(/\d/) | |
puts 'String has numbers' | |
when some_string.match(/[a-zA-Z]/) | |
puts 'String has letters' | |
else | |
puts 'String has no numbers or letters' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment