056_unions2.patch 641 B

1234567891011121314151617181920
  1. --- exercises/056_unions2.zig 2023-10-03 22:15:22.122241138 +0200
  2. +++ answers/056_unions2.zig 2023-10-05 20:04:07.096100965 +0200
  3. @@ -44,14 +44,14 @@
  4. std.debug.print("Insect report! ", .{});
  5. // Could it really be as simple as just passing the union?
  6. - printInsect(???);
  7. - printInsect(???);
  8. + printInsect(ant);
  9. + printInsect(bee);
  10. std.debug.print("\n", .{});
  11. }
  12. fn printInsect(insect: Insect) void {
  13. - switch (???) {
  14. + switch (insect) {
  15. .still_alive => |a| std.debug.print("Ant alive is: {}. ", .{a}),
  16. .flowers_visited => |f| std.debug.print("Bee visited {} flowers. ", .{f}),
  17. }