All function arguments are immutable. If a copy is desired you must explicitely
make one. Unlike variables, which use snake_case
, functions are camelCase
:
fn addFive(x: u32) u32 {
return x + 5;
}
test "function" {
const y = addFive(0);
try expect(@TypeOf(y) == u32);
try expect(y == 5);
}
Zig does not have function overloading, and it doesn't have vardiadic functions (functions with an arbitrary number of arguments). But it does have a compiler capable of creating specialized functions based on the types passed, including types inferred and created by the compiler itself.