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

Quiz* — Using the unit-scoped definition


Choose one of the declarators to make the program correct.

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


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.


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