Created
December 24, 2012 05:13
-
-
Save greenplastik/4367740 to your computer and use it in GitHub Desktop.
Problem with case statement with range and greater than comparisons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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