method subbuf
1 | role Blob |
1.1 | (Blob) method subbuf |
Documentation for method subbuf
assembled from the following types:
role Blob
From Blob
(Blob) method subbuf
Defined as:
multi method subbuf(Int , Int = self.elems --> Blob)multi method subbuf(Range --> Blob)
Extracts a part of the invocant buffer, starting from the index with elements $from
, and taking $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); # OUTPUT: «Blob:0x<03 04 05 06>»say Blob.new(1..10).subbuf(*-2); # OUTPUT: «Blob:0x<09 0a>»say Blob.new(1..10).subbuf(*-5,2); # OUTPUT: «Blob:0x<06 07>»
For convenience, also allows a Range
to be specified to indicate which part of the invocant buffer you would like:
say Blob.new(1..10).subbuf(2..5); # OUTPUT: «Blob:0x<03 04 05 06>»