Skip to content

Commit

Permalink
docs: conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
pmqueiroz committed Nov 6, 2024
1 parent 8abd1ca commit 6713b36
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/docs/examples/conditions.md
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.
1 change: 1 addition & 0 deletions docs/docs/examples/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ results in
7
9
```
Next example: [Conditions](/examples/conditions)
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ nav:
- "Values": examples/values.md
- "Variables": examples/variables.md
- "Loops": examples/loops.md
- "Conditions": examples/conditions.md

theme:
name: material
Expand Down

0 comments on commit 6713b36

Please sign in to comment.