1
0
Fork 0
mirror of https://codeberg.org/ziglings/exercises.git synced 2025-06-08 10:07:01 +09:00

Update exercises/028_defer2.zig

This commit is contained in:
Robert Voogdgeert 2023-11-03 11:55:39 +00:00
parent 7c50bd1e47
commit ec654626dd

View file

@ -15,6 +15,10 @@ pub fn main() void {
// This function is _supposed_ to print an animal name in parentheses // This function is _supposed_ to print an animal name in parentheses
// like "(Goat) ", but we somehow need to print the end parenthesis // like "(Goat) ", but we somehow need to print the end parenthesis
// even though this function can return in four different places! // even though this function can return in four different places!
// In zigling 027 runLater() is said to run when the block, within which runLater() is defined, has finished.
// In zigling 028 the block seems to be the function printAnimal, within which the to be defered print function is formulated, but the defer runs after every if{} block;
// Shoud the explantion in the comments of 027 be reformulated?
fn printAnimal(animal: u8) void { fn printAnimal(animal: u8) void {
std.debug.print("(", .{}); std.debug.print("(", .{});