Course of Raku / Advanced / More about built-in types / Native types 🆕 / Exercises / A native array
Solution: A native array
Here is a possible solution to the task.
Code
my uint8 @bytes = 100, 200, 255;
say @bytes.sum;🦋 You can find the source code in the file native-array.raku.
Output
555Comments
Putting the sized native type
uint8before the@array declares an array where every element is stored as a single unsigned byte — the compact layout that suits binary data.The wrap-around limit applies to each element (
0..255), not to the result of summing them..sumboxes the total into an ordinaryInt, so100 + 200 + 255gives the full555.
Course navigation
← A native array | Strings →