Skip to content

Instantly share code, notes, and snippets.

@ph3nx
Created January 20, 2014 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ph3nx/8529304 to your computer and use it in GitHub Desktop.
Save ph3nx/8529304 to your computer and use it in GitHub Desktop.
Some examples for the case method in Ruby.
case var
when 1
puts 1
when 2
puts 2
else
puts 'none'
end
case var
when 1 then p 1
when 2 then p 2
else p 'none'
end
message = case var
when 1 then 1
when 2 then 2
else 3
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment