Course of Raku / 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!";
}
valid This 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!";
}
invalid This program is  (: valid, invalid :) Error: Cannot use 'unit' with individual multi candidates.

Course navigation

The MAIN function / Multiple MAIN functions   |   💪 Exercises: The MAIN function

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