aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_comptime_max_with_bool.zig
blob: 4d05cbbff0aeabf3dd76564a06a0e8431e663e6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
fn max(comptime T: type, a: T, b: T) T {
    if (T == bool) {
        return a or b;
    } else if (a > b) {
        return a;
    } else {
        return b;
    }
}
test "try to compare bools" {
    try @import("std").testing.expect(max(bool, false, true) == true);
}

// test