Course of Raku / Essentials / Creating and calling functions / Default values

Quiz — Functions with default values

What is the result of calling the following function with different arguments?

sub f($a, $b = 4, $c = 5) {
    $a + $b + $c
}
10 f(1) returns  (: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 :)
8 f(1, 2) returns  (: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 :)
6 f(1, 2, 3) returns  (: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 :)

Course navigation

Creating and calling functions / Named parameters   |   💪 Exercises: Creating and calling functions

Translations of this page: EnglishDeutschEspañolItalianoLatviešuNederlandsБългарскиРусскийУкраїнська