Course of Raku / Essentials / Functions 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.

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

2

There is another function.

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

Select the correct calls of this function.

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

Course navigation

Function parameters   |   Returning the result

Translations of this page: EnglishDeutschEspañolItalianoLatviešuNederlandsБългарскиРусскийУкраїнська