routine subbuf-rw

Documentation for routine subbuf-rw assembled from the following types:

role Buf

From Buf

(Buf) method subbuf-rw

method subbuf-rw($from$length?)

A mutable version of subbuf that returns a Proxy functioning as a writable reference to a part of a buffer. Its first argument, $from specifies the index in the buffer from which a substitution should occur, and its last argument, $length specifies how many elements are to be replaced.

For example, to replace one element at index 3 with two elements, 100 and 101:

my Buf $b .= new(0..5);
say $b.perl;   # OUTPUT: «,1,2,100,101,4,5)␤» 

role Buf

From Buf

(Buf) routine subbuf-rw

sub subbuf-rw(Buf:D $buf$from$length?)

Returns a writable reference to a part of a buffer. Similar to the subbuf-rw method:

my Buf $b .= new(1,2,3);
say $b.perl;   # OUTPUT: «,2,42)␤»