Course of Raku / Essentials / More about functions / Multi-functions

Quiz 1 — Simple multi-functions

What are the correct ways to create a multi-function?

1

sub func($a) {. . .}
sub func($a, $b) {. . .}
incorrect These definitions are  (: correct, incorrect :) The multi declarator is missing.

2

multi func($a) {. . .}
multi func($a, $b) {. . .}
correct These definitions are  (: correct, incorrect :) The sub declarator is missing, but that is acceptable.

3

multi sub func($a) {. . .}
multi sub func($a, $b) {. . .}
correct These definitions are  (: correct, incorrect :) Totally perfect.

4

sub multi func($a) {. . .}
sub multi func($a, $b) {. . .}
incorrect These definitions are  (: correct, incorrect :) Should be multi sub, not sub multi.

5

multi sub func($a) {. . .}
multi sub func($b) {. . .}
incorrect These definitions are  (: correct, incorrect :) The signatures cannot be distinguished at multiple dispatch.

Course navigation

More about functions / Return type   |   💪 Exercise: Factorial with multi-functions

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