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:

  1. No arguments passed.
  2. 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

💪 Print command-line arguments

Course navigation

Typed variables / Allomorphs   |   Associative data types