vala Functions Optional parameters


Example

Parameters can be marked as optional by giving them a default value. Optional parameters can be omitted when calling the function.

string greet (string name, string language = "English") {
    if (language == "English") {
        return @"Hello, $name!";
    } else {
        return @"Sorry $name, I don't speak $language";
    }
}

greet ("John");
greet ("Jane", "Italian");