Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Created May 18, 2011 14:54
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 tjmcewan/978734 to your computer and use it in GitHub Desktop.
Save tjmcewan/978734 to your computer and use it in GitHub Desktop.
def select_animal(num)
animal = case num
when (1 or 2) then :monkey # 2 & 4 never get reached
when (3 || 4) then :giraffe
end
return animal
end
(1..4).each do |n|
puts select_animal(n)
end
# Ruby 1.9.2
# => monkey
# =>
# => giraffe
# =>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment