Course of Raku / Essentials
/ Functions essentials /
The MAIN
function / Multiple
MAIN functions
Quiz — Multi-MAIN
There are three versions of the MAIN function in this
program:
multi sub MAIN() { say 'Default mode' }
multi sub MAIN('help') { say 'Help mode' }
multi sub MAIN(Str $mode) { say "Mode '$mode'" }
What does the program print if it is run by one of the following
commands:
1
| Prints “Mode 'new'” | (: Prints “Default mode”, Prints “Help mode”, Prints “Mode 'new'”, Terminates with an exception :) |
2
| Prints “Mode '1001'” | (: Prints “Default mode”, Prints “Help mode”, Prints “Mode '1001'”, Terminates with an exception :) |
3
| Prints “Default mode” | (: Prints “Default mode”, Prints “Help mode”, Prints “Mode ''”, Terminates with an exception :) |
4
| Prints “Mode 'Help'” | (: Prints “Default mode”, Prints “Help mode”, Prints “Mode 'Help'”, Terminates with an exception :) | Parameters are case sensitive in this case. |
Course navigation
← Multiple
MAIN functions | Using
unit sub →