aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/math_add.zig
blob: 8953d057eb190f17c4feb1208b9ea1e57acfa437 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const math = @import("std").math;
const print = @import("std").debug.print;
pub fn main() !void {
    var byte: u8 = 255;

    byte = if (math.add(u8, byte, 1)) |result| result else |err| {
        print("unable to add one: {s}\n", .{@errorName(err)});
        return err;
    };

    print("result: {}\n", .{byte});
}

// exe=fail