221V 2 дней назад
Родитель
Сommit
49da424fc7
1 измененных файлов с 13 добавлено и 12 удалено
  1. 13 12
      exercises/045_optionals.zig

+ 13 - 12
exercises/045_optionals.zig

@@ -24,20 +24,20 @@
 //
 const std = @import("std");
 
-pub fn main() void {
-    const result = deepThought();
-
-    // Please threaten the result so that answer is either the
-    // integer value from deepThought() OR the number 42:
-    const answer: u8 = result;
-
-    std.debug.print("The Ultimate Answer: {}.\n", .{answer});
+pub fn main() void{
+  const result = deepThought();
+  
+  // Please threaten the result so that answer is either the
+  // integer value from deepThought() OR the number 42:
+  const answer: u8 = result orelse 42;
+  
+  std.debug.print("The Ultimate Answer: {}.\n", .{answer});
 }
 
-fn deepThought() ?u8 {
-    // It seems Deep Thought's output has declined in quality.
-    // But we'll leave this as-is. Sorry Deep Thought.
-    return null;
+fn deepThought() ?u8{
+  // It seems Deep Thought's output has declined in quality.
+  // But we'll leave this as-is. Sorry Deep Thought.
+  return null;
 }
 // Blast from the past:
 //
@@ -49,3 +49,4 @@ fn deepThought() ?u8 {
 //    var maybe_bad: Error!u32 = Error.Evil;
 //    var number: u32 = maybe_bad catch 0;
 //
+