Skip to content

Commit 1491b93

Browse files
committed
clarify invert semantics
1 parent ddcd709 commit 1491b93

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

S32-setting-library/Containers.pod

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,11 @@ function. Use a map or some such for that.
700700
=item invert
701701

702702
multi method invert ( --> List ) is export {
703-
self.map: -> $p { $.value X=> $.key }
703+
self.map: -> $p { $.value »=>» $.key }
704704
}
705705

706706
Produces a backmapping of values to keys, expanding list values
707-
into multiple pairs. (The C<< X=> >> expands C<$v> if it is a list.)
708-
To handle keys that do C<Positional> you'll need to write your own map.
707+
into multiple pairs. (The C<< »=>» >> expands the value if it is a list.)
709708

710709
The invocant must be a list containing only Pairs, and throws an error if
711710
anything that is not a Pair is passed. To get combine kv values, use
@@ -1040,12 +1039,14 @@ the keys in the hash matches.
10401039
=item invert
10411040

10421041
multi method invert ( %hash: --> List ) is export {
1043-
map -> $k, $v { $v X=> $k }, %hash.kv;
1042+
map -> $k, $v { $v »=>» $k }, %hash.kv;
10441043
}
10451044

10461045
Produces a backmapping of values to keys, expanding list values
1047-
into multiple pairs. (The C<< X=> >> expands C<$v> if it is a list.)
1048-
To handle keys that do C<Positional> you'll need to write your own map.
1046+
into multiple pairs. (The C<< »=>» >> expands C<$v> if it is a list.)
1047+
1048+
This function is essentially a shortcut for C<.pairs.invert>, but bypasses
1049+
the creation of pairs only to invert them.
10491050

10501051
=item push
10511052

0 commit comments

Comments
 (0)