File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -64,16 +64,25 @@ Applies an encoding to turn the blob into a L<Str|/type/Str>.
64
64
Defined as:
65
65
66
66
method subbuf(Int $from, Int $len = self.elems) returns Blob:D
67
+ method subbuf(Range $range) returns Blob:D
67
68
68
69
Usage:
69
70
70
71
BLOB.subbuf(FROM, LENGTH?)
72
+ BLOB.subbuf(RANGE)
71
73
72
74
Extracts a part of the invocant buffer, starting from the index with
73
75
elements C < $from > , and taking C < $len > elements (or less if the buffer is
74
76
shorter), and creates a new buffer as the result.
75
77
76
78
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>
77
86
78
87
= head2 method unpack
79
88
You can’t perform that action at this time.
0 commit comments