221V 1 week ago
parent
commit
28780ba211
1 changed files with 13 additions and 12 deletions
  1. 13 12
      exercises/015_for.zig

+ 13 - 12
exercises/015_for.zig

@@ -10,18 +10,18 @@
 //
 const std = @import("std");
 
-pub fn main() void {
-    const story = [_]u8{ 'h', 'h', 's', 'n', 'h' };
-
-    std.debug.print("A Dramatic Story: ", .{});
-
-    for (???) |???| {
-        if (scene == 'h') std.debug.print(":-)  ", .{});
-        if (scene == 's') std.debug.print(":-(  ", .{});
-        if (scene == 'n') std.debug.print(":-|  ", .{});
-    }
-
-    std.debug.print("The End.\n", .{});
+pub fn main() void{
+  const story = [_]u8{ 'h', 'h', 's', 'n', 'h' };
+  
+  std.debug.print("A Dramatic Story: ", .{});
+  
+  for(story) |scene|{
+    if(scene == 'h'){ std.debug.print(":-)  ", .{}); }
+    if(scene == 's'){ std.debug.print(":-(  ", .{}); }
+    if(scene == 'n'){ std.debug.print(":-|  ", .{}); }
+  }
+  
+  std.debug.print("The End.\n", .{});
 }
 // Note that 'for' loops also work on things called "slices"
 // which we'll see later.
@@ -29,3 +29,4 @@ pub fn main() void {
 // Also note that 'for' loops have recently become more flexible
 // and powerful (two years after this exercise was written).
 // More about that in a moment.
+