Course of Raku / Advanced / Subroutines / More on MAIN subroutines / Exercises / Add two arguments

Solution: Add two arguments

Here is a possible solution to the task.

Code

sub MAIN($a, $b) {
    say $a + $b;
}

🦋 You can find the source code in the file two-arguments.raku.

Output

$ raku two-arguments.raku 2 3
5

Comments

  1. The two positional parameters receive the two words from the command line.

  2. Command-line arguments arrive as strings, but the + operator converts them to numbers, so 2 and 3 add up to 5.

Course navigation

Add two arguments   |   Quiz — MAIN usage