Switch
Switch statement compares a variable with one or many given values and executes a block of code associated with this value when a match is found. Starting from v4.0, Sanny Builder supports it for all games.
Syntax
<var>
a global or local variable. Can be an integer, float, or string variable.
<n>
- a comma-separated list of values the variable is compared with. Sanny uses ==
operator to compare values. n
can be an integer number, float, string, also a constant.
Each case can be associated with up to 8
values.
Default case is optional and can be omitted. When provided, default must be the last in the list of cases.
Switch statement does not support any extra instructions outside of case
or default
blocks. It also does not support a "fall through" behavior usually found in C-like languages. When the case block ends, the control flow is transferred out of the switch statement.
Example
Last updated