Control Flow
Control flow statements are used to control the order in which statements are executed in a program.
These blocks allow you to execute different branches of code based on conditions:
- if statements are used to execute branches of code conditionally.
- match statements are used to execute branches of code based on pattern matching.
- surprise statements are used to randomly choose between multiple branches of code.
Loops allow you to repeat a block of code multiple times:
- repeat loops are used to execute a block of code a fixed number of times.
- for loops are used to iterate over the elements of a collection.
- loop loops are used to execute a block of code indefinitely.
- while loops are used to execute a block of code while a condition is met.
These statements allow you to exit loops early or skip iterations of loops:
- break statements are used to exit loops early.
- continue statements are used to skip the rest of the current loop iteration and continue with the next iteration.
Also, Easel has a number of asynchronous keywords which are documented in other sections but are listed here to make them easy to find:
- await is used to wait for a signal before continuing execution.
- behavior spawns a concurrent behavior that executes immediately.
- on spawns a concurrent behavior that executes whenever a signal is emitted.
- with spawns a concurrent behavior that executes once, and then again whenever a signal is emitted.
- once spawns a concurrent behavior that executes once when a signal is emitted.