Skip to content

Commit 31ac0d1

Browse files
committed
show how to handle colon lists
1 parent 86ff9ff commit 31ac0d1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/Type/Pair.pod6

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ Variants of this are
2626
:key; # same as key => True
2727
:!key; # same as key => False
2828
29+
Colon pairs can be chained without a comma to create a List of Pairs. Depending
30+
on context you may have to be explicit when assigning colon lists.
31+
32+
sub s(*%h){ say %h.perl };
33+
s :a1:b2;
34+
# OUTPUT: «{:a1, :b2}␤»
35+
36+
my $manna = :a1:b2:c3;
37+
say $manna.WHAT;
38+
# OUTPUT: «(Pair)␤»
39+
40+
$manna = (:a1:b2:c3);
41+
say $manna.WHAT;
42+
# OUTPUT: «(List)␤»
43+
2944
Any variable can be turned into a C<Pair> of its name and its value.
3045
3146
my $bar = 10;

0 commit comments

Comments
 (0)