Skip to content

Instantly share code, notes, and snippets.

@ClayShentrup
Created April 29, 2012 03:16
Show Gist options
  • Save ClayShentrup/2528600 to your computer and use it in GitHub Desktop.
Save ClayShentrup/2528600 to your computer and use it in GitHub Desktop.
Devil's advocate argument for having the case statement in Ruby
case some_value
when 1..10
"do some stuff here"
when 11..20
"do something else here"
else
"out of range"
end
# compared to
if 1..10.include?(some_value)
"do some stuff here"
elsif 11..20.include?(some_value)
"do something else here"
else
"out of range"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment