This commit is contained in:
Adam Millerchip 2021-12-25 23:46:09 +09:00
parent 356c301a9e
commit 7f02b7f304
1 changed files with 2 additions and 2 deletions

View File

@ -12,14 +12,14 @@ const MyNumberError = error{TooSmall};
pub fn main() void {
var a: u32 = addTwenty(44) catch 22;
var b: u32 = addTwenty(4) ??? 22;
var b: u32 = addTwenty(4) catch 22;
std.debug.print("a={}, b={}\n", .{ a, b });
}
// Please provide the return type from this function.
// Hint: it'll be an error union.
fn addTwenty(n: u32) ??? {
fn addTwenty(n: u32) MyNumberError!u32 {
if (n < 5) {
return MyNumberError.TooSmall;
} else {