mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-22 22:13:11 -05:00
Merge pull request #95 from ziyi-yan/main
fix loop else clause explanation
This commit is contained in:
commit
de4cf20383
1 changed files with 2 additions and 2 deletions
|
@ -13,8 +13,8 @@
|
||||||
// But what value is returned from a loop if a break statement is
|
// But what value is returned from a loop if a break statement is
|
||||||
// never reached? We need a default expression. Thankfully, Zig
|
// never reached? We need a default expression. Thankfully, Zig
|
||||||
// loops also have 'else' clauses! As you might have guessed, the
|
// loops also have 'else' clauses! As you might have guessed, the
|
||||||
// else clause is evaluated once a while condition becomes false
|
// 'else' clause is evaluated when: 1) a 'while' condition becomes
|
||||||
// or a for loop runs out of items.
|
// false or 2) a 'for' loop runs out of items.
|
||||||
//
|
//
|
||||||
// const two: u8 = while (true) break 2 else 0; // 2
|
// const two: u8 = while (true) break 2 else 0; // 2
|
||||||
// const three: u8 = for ([1]u8{1}) |f| break 3 else 0; // 3
|
// const three: u8 = for ([1]u8{1}) |f| break 3 else 0; // 3
|
||||||
|
|
Loading…
Reference in a new issue