summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-18 12:46:05 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-18 12:46:05 +0000
commita7eceb21faf04762379f2ce4d23d21bbc8c11929 (patch)
tree96816551dab17c4255e9fce32fbb48ce47bb539e /README.md
parent1d25e066fc1092ecc71a9e593b55427903d697ed (diff)
Deprecate 'repeat' (superfluous), and add named uses.
Diffstat (limited to 'README.md')
-rw-r--r--README.md17
1 files changed, 13 insertions, 4 deletions
diff --git a/README.md b/README.md
index e47f6ea..fcf1634 100644
--- a/README.md
+++ b/README.md
@@ -225,8 +225,8 @@ outer: loop {
if done { break outer; }
}
-// Repeat
-repeat 5 { ... }
+// Repeat N times
+for _ in 0..5 { ... }
```
#### Advanced Control
@@ -358,13 +358,22 @@ var drawable: Drawable = &circle;
```
#### Composition
-Use `use` to mixin fields from another struct.
+Use `use` to embed other structs. You can either mix them in (flatten fields) or name them (nest fields).
+
```zc
struct Entity { id: int; }
+
struct Player {
- use Entity; // Adds 'id' field
+ // Mixin (Unnamed): Flattens fields
+ use Entity; // Adds 'id' to Player directly
name: string;
}
+
+struct Match {
+ // Composition (Named): Nests fields
+ use p1: Player; // Accessed via match.p1
+ use p2: Player; // Accessed via match.p2
+}
```
### 10. Generics