The colon at the end of "Str:D:" signifies that it's a type constraint on what you call the method on. For example:
my Str $foo; $foo.contains("hello", 0); won't work because $foo is currently not defined, i.e. doesn't pass the :D constraint. The : at the end means that the constraint "Str:D" applies to what's before the method call, in this case $foo. In this signature, the needle is not optional, and it doesn't make sense to me to have it optional. What would it mean to ask if a string contains, but not what it's supposed to contain? Without having to look at the docs, I would expect $pos to mean the position in the string that should be checked for presence of the needle (as in: find a needle in a haystack). The return value isn't shown in this definition, but I'd say that's an oversight that should be fixed. I hope that helps! - Timo On 11/09/18 12:09, ToddAndMargo wrote: > multi method contains(Str:D: Cool:D $needle, Int(Cool:D) $pos) > > Okay, I know that > Str is a string > Cool is an object that can be treated as both a string and a number > $needle is the second optional parameter > > What is "D"? > > $needle is optional, why is it not stated as "$needle?" > > How is both Str:D: and Cool:D the first parameter? > > Why does "Str:D:" have a colon on the end and "Cool:D" does not? > > What is Int(Cool:D) ? > > What is $pos ? > > Where is it stated that it has a return a value? > > Where is it state that the return value is a boolean? > > Yours in confusion, > -T