Switch
In this section, we will guide you on how to use the Switch block.
Use Cases
In programming languages, a switch statement is a control flow statement used to execute different blocks of code based on the value of an expression. It provides a more concise and readable structure for handling multiple conditional branches compared to an if statement.
Syntax of a switch statement:
switch (expression) {
case value1:
// code to be executed if expression is equal to value1
break;
case value2:
// code to be executed if expression is equal to value2
break;
// ... more cases
default:
// code to be executed if expression is not equal to any of the above values
}
In Tapicker, the Switch block works similarly to the switch statement in programming languages, but with a few differences:
- You can set conditions for each
casewithout needing an expression on theswitchitself. - You need to add a
defaultcondition manually if required.

Adding a Case
Adding a case is simple. Just click the small icon below to add a new case.

Setting Conditions
Setting conditions for a case works the same way as in the Condition block. Please refer to that section for details.

Setting a Default (Fallback)
To set a default case, simply place the case at the end (far right) and ensure that its condition always evaluates to true.

Break
If there is no break, the program will continue executing the next case. By adding a break, the code will exit the switch statement after executing one case block.

For usage of Break block, see this section.