15_for.zig 617 B

123456789101112131415161718192021222324
  1. //
  2. // Behold the 'for' loop! It lets you execute code for each
  3. // member of an array (and things called 'slices' which we'll
  4. // get to in a bit).
  5. //
  6. // for (items) |item| {
  7. // // Do something with item
  8. // }
  9. //
  10. const std = @import("std");
  11. pub fn main() void {
  12. const story = [_]u8{ 'h', 'h', 's', 'n', 'h' };
  13. std.debug.print("A Dramatic Story: ", .{});
  14. for (???) |???| {
  15. if(scene == 'h') std.debug.print(":-) ", .{});
  16. if(scene == 's') std.debug.print(":-( ", .{});
  17. if(scene == 'n') std.debug.print(":-| ", .{});
  18. }
  19. std.debug.print("The End.\n", .{});
  20. }