Function Calls

Functions can be called (invoked). Function calls need to provide exactly as many argument values as the function has parameters.

fun double(_ x: Int): Int {
    return x * 2
}

// Valid: the correct amount of arguments is provided.
//
double(2)  // is `4`

// Invalid: too many arguments are provided.
//
double(2, 3)

// Invalid: too few arguments are provided.
//
double()

Last updated