Course of Raku / Essentials / Functions essentials / The MAIN function / Using unit sub

Quiz* — Using the unit-scoped definition

1

Choose one of the declarators to make the program correct.

unit(: my, multi, unit :) sub MAIN(Str $name);
.say "Hello, $name!";

2

Tell if the program is correct.

unit sub MAIN(Str $name) {
    say "Hello, $name!";
}
validThis program is  (: valid, invalid :)Despite the presence of unit, you can still add braces, but that is way redundant.

3

Is this program correct?

unit multi sub MAIN() {
    say 'Hello, everyone!';
}

unit multi sub MAIN($name) {
    say "Hello, $name!";
}
invalidThis program is  (: valid, invalid :)Error: Cannot use 'unit' with individual multi candidates.

Course navigation

Using unit sub   |   Hello, World!

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