mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
14 lines
278 B
Zig
14 lines
278 B
Zig
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
|