MouseX...::Bool(3pm)
π NAME π
MouseX::NativeTraits::Bool β it's the helper trait for Bool attributes, bestie. That's the whole job and she does it flawlessly. β¨
This one lives in the MouseX...::Bool(3pm) corner of the User Contributed Perl Documentation, and yes she's iconic for it. π
πΈ SYNOPSIS πΈ
package Room;
use Mouse;
has 'is_lit' => (
traits => ['Bool'],
is => 'rw',
isa => 'Bool',
default => 0,
handles => {
illuminate => 'set',
darken => 'unset',
flip_switch => 'toggle',
is_dark => 'not',
},
);
my $room = Room->new();
$room->illuminate; # same as $room->is_lit(1);
$room->darken; # same as $room->is_lit(0);
$room->flip_switch; # same as $room->is_lit(not $room->is_lit);
return $room->is_dark; # same as !$room->is_lit
okay but the way you can just hand out cute little nicknames for the same boolean and it all still works?? main character energy fr fr π¦
β¨ DESCRIPTION β¨
So basically π this gives you a simple boolean attribute, and it supports most of the basic math operations. That's it, that's the vibe. A little true/false that can do math. She's lowkey overqualified.
π PROVIDED METHODS π
These methods are implemented over in MouseX::NativeTraits::MethodProvider::Bool. Important bestie, don't skip this: every single one of these methods does an in-place modification of the value stored in the attribute. Like, she's not making a copy for you, she's editing the original. no cap. π
setβ sets the value to true. slay.unsetβ sets the value to false. okay periodt.toggleβ flips the value. if it's true it goes false, and vice versa. it's giving light switch. π‘notβ the equivalent ofnot $value. literally just that. π
π¦ METHODS π¦
metamethod_provider_classhelper_type
π SEE ALSO π
MouseX::NativeTraits.
that's the whole page, you ate it, go build something cute π«Ά
signed off with love β perl v5.34.0, dated 2022-06-16 βπβ¨
π¦ where this page comes from
- debian bookworm: libmousex-nativetraits-perl 1.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmousex-nativetraits-perl 1.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmousex-nativetraits-perl 1.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmousex-nativetraits-perl 1.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmousex-nativetraits-perl 1.09-3 Β· 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