Skip to content

Commit ffa2e50

Browse files
committed
Mention Blob.subbuf can also take a Range
1 parent e145a3c commit ffa2e50

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/Type/Blob.pod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,25 @@ Applies an encoding to turn the blob into a L<Str|/type/Str>.
6464
Defined as:
6565
6666
method subbuf(Int $from, Int $len = self.elems) returns Blob:D
67+
method subbuf(Range $range) returns Blob:D
6768
6869
Usage:
6970
7071
BLOB.subbuf(FROM, LENGTH?)
72+
BLOB.subbuf(RANGE)
7173
7274
Extracts a part of the invocant buffer, starting from the index with
7375
elements C<$from>, and taking C<$len> elements (or less if the buffer is
7476
shorter), and creates a new buffer as the result.
7577
7678
say Blob.new(1..10).subbuf(2, 4); # Blob:0x<03 04 05 06>
79+
say Blob.new(1..10).subbuf(*-2); # Blob:0x<09 0a>
80+
say Blob.new(1..10).subbuf(*-5,2); # Blob:0x<06 07>
81+
82+
For convenience, also allows a C<Range> to be specified to indicate which
83+
part of the invocant buffer you would like:
84+
85+
say Blob.new(1..10).subbuf(2..5); # Blob:0x<03 04 05 06>
7786
7887
=head2 method unpack
7988

0 commit comments

Comments
 (0)