I defined a multi sub
which has two signatures:
multi sub mie(Str $s, Int $i) { $s x $i }
multi sub mie(Int $s, Int $i) { ... }
say &mie.signature; # ;; Mu | is raw)
I want to get the signature of this multi sub
, but the above result is not what i expected.
As the document said, contains is a multi method which has 4 signatures:
multi method contains(Str:D: Cool:D $needle)
multi method contains(Str:D: Str:D $needle)
multi method contains(Str:D: Cool:D $needle, Int(Cool:D) $pos)
multi method contains(Str:D: Str:D $needle, Int:D $pos)
But when i try to get the signature of contains:
say "a string".^methods.pairs.values[8].value.signature;
It only output one signature:
(Str: | is raw)
In the REPL, when i call the contains
method without argument, it output the following error:
> "a string".contains()
Cannot resolve caller contains(Str: ); none of these signatures match:
(Str:D: Cool:D $needle, *%_)
(Str:D: Str:D $needle, *%_)
(Str:D: Cool:D $needle, Cool:D $pos, *%_)
(Str:D: Str:D $needle, Int:D $pos, *%_)
in block <unit> at <unknown file> line 1
That indicate that contains
method indeed has 4 signatures! I want to know is there any methods that can output all the signature of a method/multi method?