by Edward Stewart
Simulated example of a Switch Case using dictionaries with "Go To" and "Label" blocks.
Using Dictionaries, we can dynamically assign a label name to a variable and pass the variable to a Go To block. The Go To block passes control to the appropriate Label block, where we can have our relevant logic.
In this flow, I use a Choice Dialog to get an animal from the user and then provide information about the animal the user picked. It is important to note the quotes around the string interpolation on the Go To block. Without the quotes, we're passing a variable and its data instead of a string that matches the Label block name.
The switch case logic only requires three blocks (not including the flow beginning block):
- a block to dynamically set the variable
- a Go To block that takes the variable as a string interpolation
- at least one Label block to pass flow control too
If you have any issues, leave a comment.
Rate and review within the app in the Community section.