Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Elaborate a bit on substr-rw()
  • Loading branch information
lizmat committed Feb 23, 2015
1 parent dbee059 commit b4d74fa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions S32-setting-library/Str.pod
Expand Up @@ -471,6 +471,17 @@ string variable:
$string ~~ /(barney)/;
substr-rw($string, $0.from, $0.to) = "fred";

This writable reference can be aliased to, for repeated operations:

my $r := substr-rw($string, $0.from, $0.to);
$r = "fred"; # "barney" replaced by "fred"
$r = "wilma"; # "fred" replaced by "wilma"

Please note that only the start point is kept by the reference: any changes
to the length of the string before the start point, will render the reference
useless. So it is probably safest to keep only one writable reference per
string, or make sure that all replacement strings have the same size.

=item trim

multi method trim() is export;
Expand Down

0 comments on commit b4d74fa

Please sign in to comment.