Skip to content

Commit a066bb9

Browse files
committed
Document Buf.reallocate
1 parent 8efd70f commit a066bb9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/Type/Buf.pod6

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ For example, to replace one element at index 3 with two elements, C<100> and C<1
2727
my Buf $b .= new(0..5);
2828
$b.subbuf-rw(3,1) = Buf.new(100, 101);
2929
say $b.perl; # OUTPUT: «Buf.new(0,1,2,100,101,4,5)␤»
30+
3031
=head2 routine subbuf-rw
3132
3233
sub subbuf-rw(Buf:D $buf, $from, $length?)
@@ -37,6 +38,19 @@ Returns a writable reference to a part of a buffer. Similar to the C<subbuf-rw>
3738
subbuf-rw($b,2,1) = Buf.new(42);
3839
say $b.perl; # OUTPUT: «Buf.new(1,2,42)␤»
3940
41+
=head2 method reallocate
42+
43+
method reallocate($elems)
44+
45+
Change the number of elements of the C<Buf>. The C<Buf> will be made larger if
46+
the specified value is larger than the current number of elements. The value of
47+
newly created elements is undetermined and should thus not be relied upon. It
48+
returns the altered C<Buf>.
49+
50+
my Buf $b .= new(^10);
51+
$b.reallocate(5);
52+
say $b.perl; # OUTPUT: «Buf.new(0,1,2,3,4)␤»
53+
4054
=end pod
4155

4256
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)