subbuf
ErrorsCollection

subbuf

Synthesised documentation from type/Blob

From type/Blob

See Original text in context

multi method subbuf(Int $fromInt $len = self.elems --> Blob:D)
multi method subbuf(Range $range --> Blob:D)
multi method subbuf(Blob:D: &From)
multi method subbuf(Blob:D: Int:D $From&End)
multi method subbuf(Blob:D: &From&End)
multi method subbuf(Blob:D: \fromWhatever)
multi method subbuf(Blob:D: \fromNumeric \length)

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(24);    # 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>␤»