Kurso de Raku / Esencoj / Bazoj de funkcioj / Pli pri funkcioj / Multi-funkcioj

Kvizo 2 — Multi-funkcioj kun tipitaj parametroj

Kiaj estas la ĝustaj manieroj krei multi-funkcion?

1

multi sub func(Int $a, Int $b) {. . .}
multi sub func(Int $a, Num $b) {. . .}
correctĈi tiuj difinoj estas  (: ĝustaj, malĝustaj :)Parametraj tipoj malsamas.

2

multi sub func(Int $a, Int $b) {. . .}
multi sub func(Int $a, Int $b, Int $c) {. . .}
correctĈi tiuj difinoj estas  (: ĝustaj, malĝustaj :)Nombro de parametroj malsamas.

3

multi sub func($a) {. . .}
multi sub func(Int $a, Int $b) {. . .}
multi sub func(Int $a, Int $b, Int $c) {. . .}
correctĈi tiuj difinoj estas  (: ĝustaj, malĝustaj :)Varianto kun nur pozicia parametro estas bona.

4

multi sub func($a) {. . .}
multi sub func(Int $a) {. . .}
correctĈi tiuj difinoj estas  (: ĝustaj, malĝustaj :)La unua varianto kaptas ĉion krom Int.

Kursa navigado

Kvizo 1 — Simplaj multi-funkcioj   |   Kvizo 3 — Vokante multi-funkciojn