SPVM::I...ByteList(3)

πŸ“¦ version 0.990125, in alpine 3.24

πŸ’– NAME πŸ’–

Okay bestie, meet SPVM::Immutable::ByteList β€” an Immutable byte Array. This page is SPVM::I...ByteList(3), from User Contributed Perl Documentation, and it's giving β€œbyte list but make it immutable” energy. 🫢

✨ DESCRIPTION ✨

The Immutable::ByteList has methods to manipulate an immutable byte array. That's the whole vibe: bytes, list, but immutable. Slay. πŸ’…

πŸŽ€ USAGE πŸŽ€

Here's the demo, bestie β€” verbatim, no cap:

  use Immutable::ByteList;

  # Create a byte list
  my $list = Immutable::ByteList->new;
  my $list = Immutable::ByteList->new([(byte)1, 2, 3]);

  # Create a byte list with array length
  my $list = Immutable::ByteList->new_len(10);

  # Get list length
  my $length = $list->length;

  # Get value.
  my $element = $list->get(2);

  # Convert list to array.
  my $array = $list->to_array;

πŸ¦‹ FIELDS πŸ¦‹

length

Field declaration realness:

has length : ro int;

Gets the length field. This field is the length of the elements of the list. Short, iconic, to the point. ✨

πŸ‘‘ CLASS METHODS πŸ‘‘

new

Signature:

static method new : Immutable::ByteList ($array : byte[] = undef);

Creates a new Immutable::ByteList object using new_len. The passed length to new_len is the length of $array. If the array is undef, the length is 0. The elements of $array are copied to the elements of the created array. Copy behavior? Only for the elements, bestie. πŸŽ€

Examples:

my $list = Immutable::ByteList->new;
my $list = Immutable::ByteList->new([(byte)1, 2, 3]);

new_len

Signature:

static method new_len : Immutable::ByteList ($length : int);

Creates a new Immutable::ByteList object with $length.

Exceptions:

  • $length must be greater than or equal to 0. Otherwise an exception is thrown. πŸ’€

🌈 INSTANCE METHODS 🌈

get

Signature:

method get : int ($index : int);

Gets the element of the position of $index. If $index is a netative value, $index is set to length plus $index. (Yes bestie, β€œnetative” is exactly what the page says β€” preserve and protect. 🫢)

Exceptions:

  • $index must be greater than or equal to 0. Otherwise an exception is thrown.
  • $index must be less than the length of $list. Otherwise an exception is thrown.

to_array

Signature:

method to_array : byte[] ();

Converts the list to an array. Boom, array. πŸ¦‹

Copyright (c) 2023 Yuki Kimoto

MIT License

Final vibe check: this is perl v5.42.2, dated 2026-02-03, manual name SPVM::I...ByteList(3). Bye bestie, go manipulate those immutable bytes responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from