Docs rewrite

This commit is contained in:
2026-07-03 10:23:45 +02:00
parent 6cda69044a
commit ec857525b4
23 changed files with 1084 additions and 1134 deletions
+87
View File
@@ -0,0 +1,87 @@
---
title: Control Flow
description: If/else, while, for, c-style for, loop, match, break, continue, and return.
icon: ArrowLeftRight
---
### If/Else
```mist
if condition {
// body
} else if other_condition {
// body
} else {
// body
}
```
Conditions must be parenthesized: `if (expr) { }` or `if expr_no_struct { }` (struct literals require parentheses).
Used as an expression:
```mist
let x = if true { 1 } else { 2 };
```
### While
```mist
while condition {
// body
}
```
### For
```mist
for pattern in iterator {
// body
}
for i in 0 .. 10 {
// body
}
```
### C-Style For
```mist
for (let mut i = 0; i < 10; i++) {
// body
}
```
### Loop
```mist
loop {
// infinite loop
}
```
### Match
```mist
match value {
pattern1 => expr,
pattern2 => {
// block body
}
pattern3 | pattern4 => expr,
}
```
### Break / Continue
```mist
break;
continue;
```
### Return
```mist
return;
return value;
```