Skip to content

Instantly share code, notes, and snippets.

@greenplastik
Created December 24, 2012 05:13
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 greenplastik/4367740 to your computer and use it in GitHub Desktop.
Save greenplastik/4367740 to your computer and use it in GitHub Desktop.
Problem with case statement with range and greater than comparisons
x=40
answer = case x
when x<1 then "400"
when 1...2 then "300"
when 2...4 then "250"
when 4...6 then "150"
when 6...8 then "125"
when 8...10 then "100"
when 10...12 then "92"
when 12...15 then "85"
when 15...22.5 then "70"
when 22.5...30 then "65"
when x>=30 then "60"
else "This should output 60!. Why doesn't this work?!"
end
puts(answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment