Skip to content

Instantly share code, notes, and snippets.

@vargheseraphy
Last active July 15, 2025 22:22
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
@xiaomipkk-hue
Copy link


Uploading 17526180790426529637328309546372.jpg…

@xiaomipkk-hue
Copy link

mmk123.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment