Writing an fn Function
Strict, typed, and performance-focused.
Meet the fn Keyword
The fn keyword defines a stricter function. It trades some flexibility for safety and the speed Mojo is famous for. ⚡
fn greet():
print("Hello")Types Are Required
Every parameter in an fn must declare its type. This lets the compiler check your code and generate fast machine code.
fn add(a: Int, b: Int) -> Int:
return a + bAll lessons in this course
- Writing a def Function
- Writing an fn Function
- When to Reach for Each
- Return Types and None