develooper Front page | perl.perl6.users | Postings from September 2018

Re: .kv ?

Thread Previous | Thread Next
From:
Simon Proctor
Date:
September 14, 2018 10:29
Subject:
Re: .kv ?
Message ID:
CAGwa-ji7GYhyuHQkcbnbfG9UfsGGNjKwsXnVaYhqarWf5qYV5w@mail.gmail.com
:D means a defined value. So it's when you have an instance. :U is
undefined so it's when you call kv as a classethod.

Pair.kv would be :U.
(A => "b").kv would be :D


On Fri, 14 Sep 2018, 11:22 Todd Chester, <ToddAndMargo@zoho.com> wrote:

> Hi All,
>
> I adore the "kv" method:
>
> $ p6 'for "abc\n23\n4.56".lines.kv -> $i, $j { say "$i  $j" };'
> 0  abc
> 1  23
> 2  4.56
>
> So, I decided to go and look at:
>     https://docs.perl6.org/routine/kv
>
> multi method kv(Any:U:  -->List)
> multi method kv(Any:D:  -->List)
>
>
> Okay, here is what I see:
>
> "method"  is .foo style of a routine
>
> "Any:U:" and "Any:D:" are what goes in front of .foo
> and it can be of type "Any".
>
>       https://docs.perl6.org/type/Any
>
>       ":D" mean constrained, meaning it much have something
>
>       What is ":U"?
>
>       Whatever ":U", how can it be both?
>
> The second ":" is the delimiter for what goes in front of the .foo,
> meaning it has finished its declaration of what that in front is.
> Kind of like a comma.
>
> "-->List" mean something is returned of type "List"
>       https://docs.perl6.org/type/List
>
>       0  abc
>       1  23
>       2  4.56
>
>
> How have I done so far?
>
>
> And is there a list somewhere of the meanings of ":U" and ":D"
> and such so the next time I see one that I do not recognize,
> I can look it up?
>
> Many thanks,
> -T
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About