-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
In Umbra, conditional logic is handled using the `if`, `else if`, and `else` constructs, which allow branching based on `bool` expressions. The basic structure begins with `if`, followed by a condition enclosed in parentheses and the block of code to execute if the condition is `true`: | ||
|
||
```u title="conditions.md" | ||
if true { | ||
# Code executes if the condition is true | ||
} | ||
``` | ||
|
||
You can add an `else if` block to check additional conditions if the first one is `false`: | ||
|
||
```u title="conditions.md" | ||
else if false { | ||
# Code executes if the first condition is false, but this one is true | ||
} | ||
``` | ||
|
||
Finally, an optional `else` block can be added to handle all cases where none of the previous conditions are met: | ||
|
||
```u title="conditions.md" | ||
else { | ||
# Code executes if all previous conditions are false | ||
} | ||
``` | ||
|
||
This structure allows for clean and readable conditional branching, enabling complex decision-making within the code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,4 @@ results in | |
7 | ||
9 | ||
``` | ||
Next example: [Conditions](/examples/conditions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters