File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -903,14 +903,21 @@ one does this:
903
903
904
904
my $string = "abc";
905
905
$string.substr-rw(1, 1) = "z";
906
- $string.say; # OUTPUT: «azc»
906
+ $string.say; # OUTPUT: «azc»
907
+
908
+ Note that new characters can be inserted as well:
907
909
908
- C < substr-rw > also has a function form, so the above example can also be
910
+ $string.substr-rw(2, 0) = "-Zorro-"; # insert new characters BEFORE the character at index 2
911
+ $string.say; # OUTPUT: «az-Zorro-c»
912
+
913
+ C < substr-rw > also has a function form, so the above examples can also be
909
914
written like so:
910
915
911
916
my $string = "abc";
912
917
substr-rw($string, 1, 1) = "z";
913
- $string.say; # OUTPUT: «azc»
918
+ $string.say; # OUTPUT: «azc»
919
+ substr-rw($string, 2, 0) = "-Zorro-";
920
+ $string.say; # OUTPUT: «az-Zorro-c»
914
921
915
922
It is also possible to alias the writable reference returned by C < substr-rw >
916
923
for repeated operations:
You can’t perform that action at this time.
0 commit comments