Using IF to Evaluate a Range of Values?
coryco2
Posts: 107
I know you can use CASE to evalaute a range of values, like this:
But I'm wondering if there is some similar syntax for evaluating ranges with IF as well? The Propeller Tool won't allow this, for instance:
CASE SomeValue 10..20 : Result1 21..40 : Result2 OTHER: Result3
But I'm wondering if there is some similar syntax for evaluating ranges with IF as well? The Propeller Tool won't allow this, for instance:
IF SomeValue == 10..20 Result1 ELSEIF SomeValue == 21..40 Result2 ELSE Result3Though it appears it should be the same. (Btw, I did also try putting the ranges in brackets, parenthesis, etc. with no success). Can anyone tell me what the problem is?
Comments
Why? That's the syntax definition -- if you don't like it, do what others have and create your own language.
Clearly "if a = b " is asking if one thing has the same value, is equal to, an another thing. Does 2 = 2?, yes. Does 2 = 4?, no.
This is clear to anyone who has done maths at school.
If you want to ask a different question , like is 3 in the set of numbers {1, 2, 3, 4, 5} then you need a different notation. Enter the "case".
It's only that I'm old fashioned and I think "=" should mean "equals" as it has done in maths for a long time.
What you are asking for is an operator that tests for something being a member of a set or not. That should be a different operator to my mind.
In fact in mathematics there has been such an operator for a long time: If a is member of B, this is denoted a ∈ B
So your "if" test would be something like:
if SomeValue ∈ { 1, 2, 3, 4, 5 }
I just feel we should not break decades, or even centuries, of notation and semantics on a whim.