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

.kv ?

Thread Next
Todd Chester
September 14, 2018 10:22
.kv ?
Message ID:
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:

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".

      ":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"

      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,

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About