Parameters vs Arguments
Compile-time values versus runtime values.
Two Kinds of Input
Mojo functions can take two kinds of input: parameters known at compile time, and arguments known at runtime. Knowing the difference is the key.
Arguments Live at Runtime
An argument is an ordinary value you pass when the program runs. Its actual number can change every single time you call the function.
fn square(x: Int) -> Int:
return x * xAll lessons in this course
- Parameters vs Arguments
- Parameterized Functions
- Parameterized Structs
- Why Compile-Time Wins Speed