Switch says if variable x is v1 then do this, v2: do that and so on.
Is there a simple generalization that expresses: if x is in range [v1,v2] do something, if in [v3,v4] do something, if in [v5, v6]...
I can use if statements, but if can also be used in place of normal switch statements; Switch is a nice syntactic sugar.
There is no facility in the language to handle ranges, so you have to use if/then
Note that if the ranges partition the number space then you only need to check one value. For example, a common problem on these boards is converting a numeric grade to a letter grade:
In some cases it might also be desirable to encode the ranges in data and use a little loop to find the appropriate range, then use a case statement to select what to do.