SPVM::I...ortList(3)

πŸ“¦ version 0.990125, in alpine 3.24

🌸 Name 🌸

okay bestie, this is the User Contributed Perl Documentation page for SPVM::Immutable::ShortList β€” and yes, the manual page name is literally SPVM::I...ortList(3) with that little ellipsis moment. It's giving truncated but iconic. πŸ’…

SPVM::Immutable::ShortList β€” immutable short Array. That's the whole name vibe. πŸŽ€

✨ Description ✨

The Immutable::ShortList class has methods to manipulate an immutable short array. Lowkey straightforward, highkey useful. πŸ¦‹

πŸ’… Usage πŸ’…

  use Immutable::ShortList;

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

  # Create a short list with array length
  my $list = Immutable::ShortList->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

  has length : ro int;

Gets the length field. This field is the length of the elements of the list. Periodt. ✨

πŸ¦‹ Class Methods πŸ¦‹

new

  static method new : Immutable::ShortList ($array : short[] = undef);

Creates a new Immutable::ShortList object using new_len.

The passed length to new_len is the length of the array. If the array is undef, the length is 0.

The elements of the array are copied to the elements of the created array. No cap, they get copied-copied. 🫢

Examples:

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

new_len

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

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

Exceptions:

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

πŸ”₯ Instance Methods πŸ”₯

get

  method get : int ($index : int);

Gets the element of the position of $index.

If $index is a negative value, $index is set to length plus $index. Cute little negative-index remix. πŸ’€

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

  method to_array : short[] ();

Converts the list to an array. Slay. 🌈

Copyright (c) 2023 Yuki Kimoto

MIT License


perl v5.42.2 Β· 2026-02-03 β€” that's the source/version and date, bestie; bye! πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from