Skip to content

Commit d67841d

Browse files
authored
Merge pull request #3263 from Raku/blob-8163264
Document classes blob8, blob16, blob32 and blob64
2 parents 00cc4b2 + 2f07f48 commit d67841d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

doc/Type/Blob.pod6

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@
99
The C<Blob> role is an immutable interface to binary types, and offers a
1010
list-like interface to lists of integers, typically unsigned integers.
1111
12+
However, it's a parameterized type, and you can instantiate with several
13+
integer types:
14+
15+
=for code
16+
my $b = Blob[int32].new(3, -3, 0xff32, -44);
17+
say $b; # OUTPUT: «Blob[int32]:0x<03 -3 FF32 -2C>»
18+
19+
By default, C<Blob> uses 8-bit unsigned integers, that is, it is
20+
equivalent to Blob[uint8]. Some other types of C<Blob>s which are used
21+
often get their own class name.
22+
23+
X<|blob8>X<|blob16>X<|blob32>X<|blob64>
24+
=begin table
25+
blob8 | Blob[uint8]
26+
blob16 | Blob[uint16]
27+
blob32 | Blob[uint32]
28+
blob64 | Blob[uint64]
29+
=end table
30+
31+
You can use these in pretty much the same way you would with C<Blob>:
32+
33+
my $blob = blob8.new(3, 6, 254);
34+
say $blob; # OUTPUT: «Blob[uint8]:0x<03 06 FE>␤»
35+
1236
=head1 Methods
1337
1438
=head2 method new

0 commit comments

Comments
 (0)