4 ms·
What it does have is compile-time parameters where you can bind a type variable during compilation: fn max(comptime T: type, a: T, b: T) T { if (T == b
by mborch 8y ago
What it does have is compile-time parameters where you can bind a type variable during compilation:
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;
}
}
The type variable isn't used at run-time.