List::...utable(3pm)

πŸ“¦
version 2.028003 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

List::Objects::WithUtils::Role::Array::Immutable β€” bestie, it's giving immutable array behavior ✨


🌸 SYNOPSIS 🌸

  # Via List::Objects::WithUtils::Array::Immutable ->
  use List::Objects::WithUtils 'immarray';
  my $array = immarray(qw/ a b c /);
  $array->push('d');  # dies

See that last line? Yeah. It dies. The array said no. Iconic behavior honestly πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so listen β€” this role is the chill-but-firm friend who adds immutable behavior to anyone consuming List::Objects::WithUtils::Role::Array. Once you're in this role, the array is locked in. No take-backs. No edits. It's giving "we're not doing that today" energy πŸ’€

The following methods are not available and will throw an exception if you even try:

  • clear
  • set
  • pop push
  • shift unshift
  • delete delete_when
  • insert
  • rotate_in_place
  • splice

Like… don't even attempt it, bestie. It's not a vibe check you're gonna pass. πŸ™ˆ

(The backing array is also marked read-only.) So it's locked from every angle, no cap πŸ”’βœ¨


Wanna actually use this thing? Peep List::Objects::WithUtils::Array::Immutable β€” that's a consumer implementation that also pulls in List::Objects::WithUtils::Role::Array & List::Objects::WithUtils::Role::Array::WithJunctions. Two-for-one slay 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Jon Portnoy <avenj@cobaltirc.org>

Licensed under the same terms as Perl. πŸŽ€


And that's the whole page, bestie β€” brought to you by perl v5.38.2, dated 2024-03-07, from the User Contributed Perl Documentation squad. Go forth and don't mutate anything πŸ’œπŸŒΈ

πŸ“¦ where this page comes from