Statements
Statements in Rell are essential for controlling program flow and data handling. This section explores variable declarations, conditionals, and loops, providing the foundation for building structured and effective Rell programs.
Declare constants with val and mutable variables with var. Constants are immutable and can exist outside functions, while variables can be modified within their scope.
Learn Rell's basic statements for assigning values, calling functions, returning values, and grouping code blocks for organized data manipulation and control flow.
Use the if statement for conditional logic, with optional else blocks and else-if chains, and the when statement for multi-way branching similar to switch in other languages. Both also exist in expression form.
Control loops with for, while, break, and continue statements. The for loop iterates over ranges or collections, while the while loop continues as long as a condition is true. Use break to exit loops early and continue to skip to the next iteration.