List::...::Typed(3pm)
β¨ NAME β¨
List::Objects::WithUtils::Role::Hash::Typed β it's the type-checking hash behavior role, bestie π
(it lives in the List::...::Typed(3pm) manual, iykyk)
πΈ SYNOPSIS πΈ
# Via List::Objects::WithUtils::Hash::Typed ->
use List::Objects::WithUtils 'hash_of';
use Types::Standard -all;
my $arr = hash_of(Int, foo => 1, bar => 2);
$arr->set(baz => 3.14159); # dies, failed type check
π DESCRIPTION π
Okay so this role is literally the vibe check for your hashes π«Ά. It uses Type::Tie to bolt type-checking behavior onto anyone consuming List::Objects::WithUtils::Role::Hash. No cap.
The first argument you pass to the constructor should be a Type::Tiny type β or any other object conforming to Type::API, as of "v2.25" β:
use Types::Standard -all;
my $arr = hash_of ArrayRef() => (foo => [], bar => []);
Values get checked against the type you specified when the object is constructed or when new elements get added. Every single time. She's watching π.
If that initial type-check fails, a coercion is attempted. Girl tries her best.
Values that cannot be coerced will throw an exception π so like, don't try it.
Also see Types::Standard, List::Objects::Types β they're the friends of the family π.
π¦ type π¦
Returns the Type::Tiny type the object was created with. Just hands you the receipts, periodt.
π untyped π
Returns a (shallow) clone that is a plain List::Objects::WithUtils::Hash. She took off the sparkle and went au naturel β¨.
π AUTHOR π
Jon Portnoy <avenj@cobaltirc.org>; typed hashes implemented by Toby Inkster (CPAN: TOBYINK) π«‘
and that's the whole page, bestie π β this lil gem is from perl v5.38.2, dated 2024-03-07, and it lives in the List::...::Typed(3pm) manual under User Contributed Perl Documentation. slay, go type-check something π
π¦ where this page comes from
- debian trixie: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblist-objects-withutils-perl 2.028003-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms