mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
15 lines
278 B
Zig
15 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
|