Use the if statement when:
- There are no more than two discrete values for which to test.
- There are a large number of values that can be easily separated into ranges.
Use the switch statement when:
- There are more than two but fewer than 10 discrete values for which to test.
- There are no ranges for conditions because the values are nonlinear.
Use array lookup when:
- There are more than 10 values for which to test.
- The results of the conditions are single values rather than a number of actions to be taken.
No comments:
Post a Comment