Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Use of switch function
Use of switch function
The parameter list of the switch function consists of several pairs of expressions and numerical values. Expressions are evaluated from left to right and return when the first related expression is true. If some of them are not paired, there will be operational errors. If expr- 1 is true, the switch returns-1; If expr- 1 is false, but expr-2 is true, the switch returns -2, and so on.

When none of the expressions is true, or the corresponding value of the first true expression is empty, Switch will return a null value.

Although Switch returns only one of the values, it evaluates all expressions. So pay attention to its side effects. For example, as long as one of the expressions causes a divide-by-zero error, the operation will go wrong.