Skip to content

Commit 444f8c0

Browse files
committed
fix trans for Pairs and list of Pairs
1 parent 47c01e8 commit 444f8c0

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

doc/Type/Str.pod

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -691,17 +691,20 @@ Example:
691691
multi method trans(Str:D: Pair:D \what, *%n) returns Str
692692
multi method trans(Str:D: *@changes, :complement(:$c), :squash(:$s), :delete(:$d)) returns Str
693693
694-
Replaces one or many substrings with one or many strings. Ranges are supported, both for keys and
695-
values. Regexes work as keys. When called with C<:complement> anything but the matched value or range
696-
is replaced with a single value. With C<:delete> the matched characters are removed.
697-
Combining C<:complement> and C<:delete> will remove anything but the matched values.
698-
The adverb C<:squash> will reduce repeated matched characters to a single character.
694+
Replaces one or many characters with one or many characters. Ranges are
695+
supported, both for keys and values. Regexes work as keys. In case a list of
696+
keys and values is used, substrings can be replaced aswell. When called with
697+
C<:complement> anything but the matched value or range is replaced with a
698+
single value. With C<:delete> the matched characters are removed. Combining
699+
C<:complement> and C<:delete> will remove anything but the matched values. The
700+
adverb C<:squash> will reduce repeated matched characters to a single
701+
character.
699702
700703
Example:
701704
702705
my $str = 'say $x<b> && $y<a>';
703-
$str.=trans( '<' => '&lt;' );
704-
$str.=trans( '<' => '&lt;', '>' => '&gt;' );
706+
$str.=trans( '<' => '«' );
707+
$str.=trans( '<' => '«', '>' => '»' );
705708
706709
$str.=trans( [ '<' , '>' , '&' ] =>
707710
[ '&lt;', '&gt;', '&amp;' ]);

0 commit comments

Comments
 (0)