Skip to content

Instantly share code, notes, and snippets.

@wrburgess
Created March 10, 2012 19:30
Show Gist options
  • Save wrburgess/2012625 to your computer and use it in GitHub Desktop.
Save wrburgess/2012625 to your computer and use it in GitHub Desktop.
ruby case/when example #ruby #example #logic #structure #case
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