Course of Raku / Essentials / Functions essentials / Creating and calling functions / Returning the result

Quiz — Return from a function

1

What does this function return?

sub f($a, $b) {
    return $a + $b if $a > $b;
    return 42;
}
42f(1, 2) returns  (: 1, 2, 3, 42 :)
3f(2, 1) returns  (: 1, 2, 3, 42 :)
42f(2, 2) returns  (: 1, 2, 3, 42 :)

2

What does this function return?

sub g() {
    return -1;
    1;
}
−1g() returns  (: −1, 1 :)The last expression 1; is never reached.

Course navigation

Returning the result   |   Positional parameters

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