Skip to content

Instantly share code, notes, and snippets.

@vargheseraphy
Last active August 29, 2015 14:14
Show Gist options
  • Save vargheseraphy/9007d6e141a442ea18a0 to your computer and use it in GitHub Desktop.
Save vargheseraphy/9007d6e141a442ea18a0 to your computer and use it in GitHub Desktop.
switch case in ruby
case a
when 1
puts "Single value"
when 2, 3
puts "One of comma-separated values"
when 4..6
puts "One of 4, 5, 6"
when 7...9
puts "One of 7, 8, but not 9"
when 1..4, 5
puts "It's between 1 and 5"
else
puts "Any other thing"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment