0Pricing
Mojo Academy · Lesson

Positional and Keyword Arguments

Send values by position or by name.

Two Ways to Pass Values

Every Mojo function call sends in values called arguments. You can send them by position or by name, and both styles can live in one call.

Positional Arguments

With positional arguments, order is everything. The first value fills the first parameter, the second fills the second, and so on.

fn greet(name: String, times: Int):
    for _ in range(times):
        print(name)

greet("Mojo", 2)

All lessons in this course

  1. Positional and Keyword Arguments
  2. Default Argument Values
  3. Returning Multiple Values
  4. Reading Function Signatures
← Back to Mojo Academy