Course of Raku / Essentials / Creating and calling functions / Function parameters

Passing arguments

1

There is a function with the following definition:

sub f {
    say 'Function called';
}

Choose the correct calls of this function.

1 f;  
0 f(''); Function does not accept any arguments, but one is received here.
0 f ''; The same as above.
1 f(); This is fine, no arguments passed.
0 f (); Here, one argument (an empty list) is passed.
0 f(10);  

2

There is another function.

sub g($x, $y) {
    say "Called g($x, $y)";
}

Select the correct calls of this function.

1 g(10, 20);  
0 g 10 20; No comma between arguments.
0 g(10); Too few arguments: two required, one passed.
1 g 10, 20; Parentheses are not required when it is not ambiguous.
0 g(10,); Not a valid syntax.
0 g(,20); Not a valid syntax either.
0 g('10, 20'); A single string argument passed.
1 g('word', 20); Arguments can be of different types.
0 g(10, 20, 30); Too many arguments.
0 g 10, 20, 30; Same here: three arguments are passed.

Course navigation

Creating and calling functions / Function names   |   Creating and calling functions / Returning the result


💪 Or jump directly to the exercises to this section.