Skip navigation.
 
mlRe: Can switch be used here?
FROM : Brad Bumgarner
DATE : Mon Jul 24 19:28:49 2006

Thanks for the info Chas.

Brad


On Jul 24, 2006, at 11:22 AM, Chas Spillar wrote:

> If I remember correctly, a switch statement case must be a compiled 
> time
> integral value.  That is, once the compilation is finished the 
> value of the
> case must be known.  Thus, what you describe (using a boolean 
> value) would
> not work.  If you can map the various boolean cases to  match a single
> integral value then it can be made to work.  However, a laddered
> if-then-else would be clearer.
>
> E.g.
>
> If (f==0) {
> } else if (l = 0) {
> } else if (f > l) {
> } else if (f == l) {
> } else if (f < l) {
> }
>
> Better would be to just subtract the two counts:
>
> f - l
>
> If the value is negative f is smaller than l, if the value is 
> positive then
> f is greater than l, if the value is 0 they are equivalent.
>
> Chas.

Related mailsAuthorDate
mlCan switch be used here? Brad Bumgarner Jul 24, 19:13
mlRe: Can switch be used here? Chas Spillar Jul 24, 19:22
mlRe: Can switch be used here? Brad Bumgarner Jul 24, 19:28