In role Buf§

See primary documentation in context for method reallocate

method reallocate(Buf:D: Int:D $elems)

Change the number of elements of the Buf, returning the changed Buf. The size of Buf will be adapted depending on the number of $elems specified: if it is smaller than the actual size of the Buf the resulting Buf will be shrunk down, otherwise it will be enlarged to fit the number of $elems. In the case the Buf is enlarged, newly created items will be assigned a Virtual Machine specific null value, therefore you should not rely upon their value since it could be inconsistent across different virtual machines.

my Buf $ .= new(^10);
$.reallocate(5);
say $.raku;  # OUTPUT: «Buf.new(0,1,2,3,4)␤» 
 
$ = Buf.new1..3 );
$.reallocate10 );
say $.raku# OUTPUT: «Buf.new(1,2,3,0,0,0,0,0,0,0)␤»