221V 4 days ago
parent
commit
6257a77333
1 changed files with 23 additions and 21 deletions
  1. 23 21
      exercises/032_unreachable.zig

+ 23 - 21
exercises/032_unreachable.zig

@@ -19,26 +19,28 @@
 //
 //
 const std = @import("std");
 const std = @import("std");
 
 
-pub fn main() void {
-    const operations = [_]u8{ 1, 1, 1, 3, 2, 2 };
-
-    var current_value: u32 = 0;
-
-    for (operations) |op| {
-        switch (op) {
-            1 => {
-                current_value += 1;
-            },
-            2 => {
-                current_value -= 1;
-            },
-            3 => {
-                current_value *= current_value;
-            },
-        }
-
-        std.debug.print("{} ", .{current_value});
+pub fn main() void{
+  const operations = [_]u8{ 1, 1, 1, 3, 2, 2 };
+  
+  var current_value: u32 = 0;
+  
+  for(operations) |op|{
+    switch(op){
+      1 => {
+        current_value += 1;
+      },
+      2 => {
+        current_value -= 1;
+      },
+      3 => {
+        current_value *= current_value;
+      },
+      else => { unreachable; },
     }
     }
-
-    std.debug.print("\n", .{});
+    
+    std.debug.print("{} ", .{current_value});
+  }
+  
+  std.debug.print("\n", .{});
 }
 }
+