Skip to content

Commit

Permalink
Expands allocate refs #2694
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Mar 26, 2019
1 parent 8c8c8d6 commit a87cda0
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions doc/Type/Blob.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Defined as:
multi method new(Blob: Blob:D $blob)
multi method new(Blob: int @values)
multi method new(Blob: @values)
multi method new(Blob: *@values) {
multi method new(Blob: *@values)
Creates an empty C<Blob>, or from another C<Blob>, from a list of integers or
from a list of values
Creates an empty C<Blob>, or a new C<Blob> from another C<Blob>, or from a list
of integers or values (which will have to be coerced into integers):
my $blob = Blob.new([1, 2, 3]);
say Blob.new(<1 2 3>); # OUTPUT: «Blob:0x<01 02 03>␤»
Expand Down Expand Up @@ -130,18 +130,26 @@ part of the invocant buffer you would like:
Defined as:
multi method allocate($elems --> Blob:D)
multi method allocate($elems, $pattern --> Blob:D)
multi method allocate(Blob:U: Int:D $elements)
multi method allocate(Blob:U: Int:D $elements, int $value)
multi method allocate(Blob:U: Int:D $elements, Int:D \value)
multi method allocate(Blob:U: Int:D $elements, Mu:D $got)
multi method allocate(Blob:U: Int:D $elements, int @values)
multi method allocate(Blob:U: Int:D $elements, Blob:D $blob)
multi method allocate(Blob:U: Int:D $elements, @values)
Returns a newly created C<Blob> object with the given number of elements.
Optionally takes a second argument that indicates the pattern with which to
fill the C<Blob>: this can be a single integer value, or any C<Iterable>
that generates integer values, including another C<Blob>. The pattern will be repeated if not enough
values are given to fill the entire C<Blob>.
Optionally takes a second argument that indicates the pattern with which to fill
the C<Blob>: this can be a single (possibly native) integer value, or any
C<Iterable> that generates integer values, including another C<Blob>. The
pattern will be repeated if not enough values are given to fill the entire
C<Blob>.
my Blob $b0 = Blob.allocate(10,0);
$b0.say; # OUTPUT: «Blob:0x<00 00 00 00 00 00 00 00 00 00>␤»
If the pattern is a general C<Mu> value, it will fail.
=head2 method unpack
This method is considered B<experimental>, in order to use it you will need to
Expand Down

0 comments on commit a87cda0

Please sign in to comment.