From 469d4dfbf40dd5512f53ce1cb022e1aa4639443b Mon Sep 17 00:00:00 2001 From: Dave Gauer Date: Wed, 12 May 2021 21:36:57 -0400 Subject: add ex087 async 4 --- exercises/087_async4.zig | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 exercises/087_async4.zig (limited to 'exercises/087_async4.zig') diff --git a/exercises/087_async4.zig b/exercises/087_async4.zig new file mode 100644 index 0000000..bb9c9ec --- /dev/null +++ b/exercises/087_async4.zig @@ -0,0 +1,30 @@ +// +// It has probably not escaped your attention that we are no +// longer capturing a return value from foo() because the 'async' +// keyword returns the frame instead. +// +// One way to solve this is to use a global variable. +// +// See if you can make this program print "1 2 3 4 5". +// +const print = @import("std").debug.print; + +var global_counter: i32 = 0; + +pub fn main() void { + var foo_frame = async foo(); + + while (global_counter <= 5) { + print("{} ", .{global_counter}); + ??? + } + + print("\n", .{}); +} + +fn foo() void { + while (true) { + ??? + ??? + } +} -- cgit v1.2.3-ZIG