Course of Raku / Essentials / Positional data types / Exercises / The number of command-line arguments
Solution: The number of command-line arguments
The solution is quite simple.
Code
say @*ARGS.elems;
Alternatively, you can chain all the methods:
@*ARGS.elems.say;
🦋 Find the program in the file number-of-command-line-arguments.raku.
Output
This program requires a test of two cases:
- No arguments passed.
- Some non-zero number of arguments passed.
$ raku exercises/positionals/number-of-command-line-arguments.raku
0
$ raku exercises/positionals/number-of-command-line-arguments.raku one 2 three 4 five 6 seven
7
Next exercise
Course navigation
← Typed variables / Allomorphs | Associative data types →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська