This commit is contained in:
parent
32bc21cebc
commit
0bd5b2aa0d
|
@ -29,17 +29,18 @@ const MyNumberError = error{
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() void {
|
||||
var nums = [_]u8{ 2, 3, 4, 5, 6 };
|
||||
const nums = [_]u8{ 2, 3, 4, 5, 6 };
|
||||
|
||||
for (nums) |num| {
|
||||
std.debug.print("{}", .{num});
|
||||
|
||||
var n = numberMaybeFail(num);
|
||||
const n = numberMaybeFail(num);
|
||||
if (n) |value| {
|
||||
std.debug.print("={}. ", .{value});
|
||||
} else |err| switch (err) {
|
||||
MyNumberError.TooBig => std.debug.print(">4. ", .{}),
|
||||
// Please add a match for TooSmall here and have it print: "<4. "
|
||||
MyNumberError.TooSmall => std.debug.print("<4. ", .{}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue