diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-18 12:46:05 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-18 12:46:05 +0000 |
| commit | a7eceb21faf04762379f2ce4d23d21bbc8c11929 (patch) | |
| tree | 96816551dab17c4255e9fce32fbb48ce47bb539e /README.md | |
| parent | 1d25e066fc1092ecc71a9e593b55427903d697ed (diff) | |
Deprecate 'repeat' (superfluous), and add named uses.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -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 |
