Course of Raku / 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;
}
42 | f(1, 2) returns (: 1, 2, 3, 42 :) |
3 | f(2, 1) returns (: 1, 2, 3, 42 :) |
42 | f(2, 2) returns (: 1, 2, 3, 42 :) |
2
What does this function return?
sub g() {
return -1;
1;
}
−1 | g() returns (: −1, 1 :) |
The last expression 1; is never reached. |
Course navigation
← Creating and calling functions / Function parameters | Creating and calling functions / Positional parameters →
💪 Or jump directly to the exercises to this section.
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська