Course of Raku / Essentials
/ Functions essentials /
The MAIN
function
Multiple MAIN
functions
Like any other function in Raku, the MAIN function can
have its multi variants. It allows the program to
individually react to a different number or different types of input
parameters.
multi sub MAIN($a) {
say 2 * $a;
}
multi sub MAIN($a, $b) {
say $a + $b;
}This program doubles its only argument or adds it to the second argument if it is present:
$ raku t.raku 21
42
$ raku t.raku 21 33
54Practice
Complete the quiz that covers the contents of this topic.
Course navigation
← Quiz
— Default values | Quiz
— Multi-MAIN →
💪 Or jump directly to the exercises in this
section.
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська