Is there a Perl 6 equivalent of a byte array?

  • A+

Let's take a Java example of byte[] data. In a method signature for Perl, I can do method myMethod($data) but this is a form of dynamic typing which is useful.

However, I wish to manipulate an array of bytes - So is there a preferred way to transform data types into a byte array or something remotely similar?

I have looked around, and have seen this code here to transform source data into a byte array:

my $arr ='mystring'.encode('utf-8'));  say $arr; 

Would this just be the preferred input into my method(s) that will manipulate the Buf through the $data method variable?


Not sure about the question, but is this what you're looking for?

my int8 @a = ^10;         # a native array of 8-bit signed bytes sub frobnicate(int8 @b) { # a sub taking a native 8-bit array     dd @b; } frobnicate @a; # array[int8].new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: