diff --git a/md/learn/flow-control/break-continue.md b/md/learn/flow-control/break-continue.md deleted file mode 100644 index e69de29..0000000 diff --git a/md/learn/flow-control/loops.md b/md/learn/flow-control/loops.md index 75e420d..758a017 100644 --- a/md/learn/flow-control/loops.md +++ b/md/learn/flow-control/loops.md @@ -19,7 +19,7 @@ for #(index, number) in numbers.entries() ``` ```thp -val dict = Obj { +val dict = .{ apple: 10, banana: 7, cherries: 3, @@ -58,7 +58,7 @@ while index < colors.size() ## Infinite loop -Basically Rust*'s loop. +Instead of doing `while true {}` use `loop`. ```thp loop @@ -72,8 +72,22 @@ loop } ``` -* Rust is a trademark of the Rust Foundation. THP is not affiliated, -endorsed or supported by the Rust Foundation. + +## Labelled loops + +You can give labels to loops, allowing you to `break` and `continue` in nested loops. + +```thp +:top for i in values_1 +{ + for j in values_2 + { + // ... + break :top + } +} +``` + diff --git a/md/learn/index.yaml b/md/learn/index.yaml index 16111e7..5320cbe 100644 --- a/md/learn/index.yaml +++ b/md/learn/index.yaml @@ -20,6 +20,8 @@ children: - name: Flow control path: flow-control children: + - name: Blocks + path: blocks - name: Conditionals path: conditionals - name: Loops