Skip to content

Commit 7351392

Browse files
committed
Document tr///
1 parent 20f3aff commit 7351392

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/Language/operators.pod6

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@ warning. To execute the substitution on a variable that isn't the C<$_> this
183183
operator uses, alias it to C<$_> with C<given>, C<with>, or any other way.
184184
Alternatively, use the L«C<.subst> method|/routine/subst».
185185
186+
=head2 C<tr///> in-place transliteration
187+
188+
my $str = 'old string';
189+
$str ~~ tr/dol/wne/;
190+
say $str; # OUTPUT: «new string␤»
191+
192+
Operates on C<$_> topical variable, changing it in place. Behaves similar to
193+
L«C<Str.trans>|/routine/trans» called with a single L<Pair> argument where
194+
key is the matching part (characters C<dol> in example above) and value is
195+
the replacement part (characters C<wne> in the example above). Accepts the
196+
same adverbs as L«C<Str.trans>|/routine/trans». Returns L<StrDistance> object
197+
that measures the distance between original value and the resultant string.
198+
186199
=head1 Assignment Operators
187200
188201
Infix operators can be combined with the assignment operator to modify a

0 commit comments

Comments
 (0)