Skip to content

Commit eac6eda

Browse files
authored
Show Associative-like access of Pair
And fix some output comment formatting.
1 parent 8bb51f8 commit eac6eda

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

doc/Type/Pair.pod6

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ possible to change the value from outside of the C<Pair> itself:
7474
=begin code
7575
my $v = 'value A';
7676
my $pair = a => $v;
77-
$pair.say; # OUTPUT: a => value A
77+
$pair.say; # OUTPUT: «a => value A␤»
7878
7979
$v = 'value B';
80-
$pair.say; # OUTPUT: a => value B
80+
$pair.say; # OUTPUT: «a => value B␤»
8181
=end code
8282
8383
Please also note that this behavior is totally unrelated to the way used to
@@ -93,9 +93,16 @@ my $v = 'value B';
9393
my $pair = a => $v;
9494
$pair.freeze;
9595
$v = 'value C';
96-
$pair.say; # OUTPUT: a => value B
96+
$pair.say; # OUTPUT: «a => value B␤»
9797
=end code
9898
99+
As Pair implements L<Associative|/type/Associative> role, its value can be
100+
accessed using Associative subscription operation. Subscrip adverbs work as well.
101+
102+
=for code
103+
my $pair = a => 5;
104+
say $pair<a>; # OUTPUT: «5␤»
105+
say $pair<a>:exists; # OUTPUT: «True␤»
99106
100107
=head1 Methods
101108

0 commit comments

Comments
 (0)