zig/doc/langref/testing_null_with_if.zig

13 lines
258 B
Zig

const print = @import("std").debug.print;
pub fn main() void {
const optional_number: ?i32 = null;
if (optional_number) |number| {
print("got number: {}\n", .{number});
} else {
print("it's null\n", .{});
}
}
// exe=succeed