method reallocate
1 | role Buf |
1.1 | (Buf) method reallocate |
Documentation for method reallocate
assembled from the following types:
role Buf
From Buf
(Buf) method reallocate
method reallocate()
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 .perl; # OUTPUT: «Buf.new(0,1,2,3,4)»= Buf.new( 1..3 );.reallocate( 10 );.perl.say; # OUTPUT: «Buf.new(1,2,3,0,0,0,0,0,0,0)»