In answer to "why the : between Str:D and Cool:D and why Int(Cool:D) ?" can I just point out the video I linked (or the slides) which answer both of these questions.
On Wed, 12 Sep 2018 at 06:29 ToddAndMargo <toddandma...@zoho.com> wrote: > On 09/11/2018 03:09 AM, 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 > > First off, I band the heck out of "contains" all over my code. > I know how it works. What I don't know is how the documentation > got there. > > Okay I am making progress. > > "multi method contains" means that it is a "method" (.foo). > Perl 6 has "methods" `.foo` and subroutines `sub foo(...){...}` > > "Str:D" means it reads a string Str.contains(...) and > that the string is mandatory (constrained). > > Okay, foul! > Str:D: Cool:D $needle > why is there not a comma between "Str:D:" and "Cool:D"? > And what is with the extra ":". By chance is the extra ":" > a confusing way of using a comma for a separator? > > "Cool:D $needle" means that sub string or number you are > looking for. And it is constrained. You must enter a value. > > Foul again! > Int(Cool:D) $pos > Why "Int(Cool:D)"? Why is type Int being redefined > as type "Cool" (number or any type or a string). > > $pos is the starting position to check for a match, > start at zero. > > Foul! > $pos is optional. But there is a "D" in its definition > making it constrained and not optional. > > And another foul! > There is no stating what the return value is. It > should be of single value of type Bool. > > I am getting there. Thank you all for the help. > > -T > > > > > > > > > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Computers are like air conditioners. > They malfunction when you open windows > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > -- Simon Proctor Cognoscite aliquid novum cotidie