diff options
author | Dave Gauer <dave@ratfactor.com> | 2021-02-07 11:06:51 -0500 |
---|---|---|
committer | Dave Gauer <dave@ratfactor.com> | 2021-02-07 11:06:51 -0500 |
commit | adf5ddb27df7f5a22b0b7d3321dfc8bca1e7937a (patch) | |
tree | a25511c3bb20069f1d6123366573c82c5745338b /14_while4.zig | |
parent | 507355ec3b1066c707e19816b86ac1fb56fc0385 (diff) | |
download | ziglings-adf5ddb27df7f5a22b0b7d3321dfc8bca1e7937a.tar.gz ziglings-adf5ddb27df7f5a22b0b7d3321dfc8bca1e7937a.tar.bz2 ziglings-adf5ddb27df7f5a22b0b7d3321dfc8bca1e7937a.tar.xz ziglings-adf5ddb27df7f5a22b0b7d3321dfc8bca1e7937a.zip |
Consistent instructions and examples
I started off with "hints" that required the poor student to piece
together the information from incomplete bits. A complete example is
like a picture that is worth 1000 words and far clearer.
Diffstat (limited to '14_while4.zig')
-rw-r--r-- | 14_while4.zig | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/14_while4.zig b/14_while4.zig index e686f88..a28b9a9 100644 --- a/14_while4.zig +++ b/14_while4.zig @@ -1,20 +1,22 @@ // -// Continue expressions do NOT execute when a while loop stops -// because of a 'break' statement. -// -// Example: +// You can force a loop to exit immediately with a "break" statement: // // while (condition) : (continue expression){ +// // if(other condition) break; -// ... +// // } // +// Continue expressions do NOT execute when a while loop stops +// because of a break! +// const std = @import("std"); pub fn main() void { var n: u32 = 1; // Oh dear! This while loop will go forever!? + // Please fix this so the print statement below gives the desired output. while (true) : (n+=1) { if(???) ???; } |