Function Overloading

🚧 Status: Function overloading is not implemented.

It is possible to declare functions with the same name, as long as they have different sets of argument labels. This is known as function overloading.

// Declare a function named "assert" which requires a test value
// and a message argument.
//
fun assert(_ test: Bool, message: String) {
    // ...
}

// Declare a function named "assert" which only requires a test value.
// The function calls the `assert` function declared above.
//
fun assert(_ test: Bool) {
    assert(test, message: "test is false")
}

Last updated