Skip to content

Commit

Permalink
Mention Blob.subbuf can also take a Range
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Nov 14, 2015
1 parent e145a3c commit ffa2e50
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/Type/Blob.pod
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,25 @@ Applies an encoding to turn the blob into a L<Str|/type/Str>.
Defined as:
method subbuf(Int $from, Int $len = self.elems) returns Blob:D
method subbuf(Range $range) returns Blob:D
Usage:
BLOB.subbuf(FROM, LENGTH?)
BLOB.subbuf(RANGE)
Extracts a part of the invocant buffer, starting from the index with
elements C<$from>, and taking C<$len> elements (or less if the buffer is
shorter), and creates a new buffer as the result.
say Blob.new(1..10).subbuf(2, 4); # Blob:0x<03 04 05 06>
say Blob.new(1..10).subbuf(*-2); # Blob:0x<09 0a>
say Blob.new(1..10).subbuf(*-5,2); # Blob:0x<06 07>
For convenience, also allows a C<Range> to be specified to indicate which
part of the invocant buffer you would like:
say Blob.new(1..10).subbuf(2..5); # Blob:0x<03 04 05 06>
=head2 method unpack
Expand Down

0 comments on commit ffa2e50

Please sign in to comment.