MouseX...ts::Num(3pm)
π MouseX::NativeTraits::Num π
okay bestie, gather round, because we're talking about MouseX::NativeTraits::Num β the helper trait for Num attributes, straight out of the User Contributed Perl Documentation. she's a perl 3pm page and she's here to make your numbers do little tricks. π
β¨ NAME β¨
MouseX::NativeTraits::Num β Helper trait for Num attributes π
πΈ SYNOPSIS πΈ
okay so here's the whole vibe, literally copy-paste this energy:
package Real;
use Mouse;
has 'integer' => (
traits => ['Number'],
is => 'ro',
isa => 'Num',
default => 5,
handles => {
set => 'set',
add => 'add',
sub => 'sub',
mul => 'mul',
div => 'div',
mod => 'mod',
abs => 'abs',
},
);
my $real = Real->new();
$real->add(5); # same as $real->integer($real->integer + 5);
$real->sub(2); # same as $real->integer($real->integer - 2);
see how clean that is?? the handles block is basically handing you a whole little math toolkit and you didn't even break a sweat. no cap. π₯
π¦ DESCRIPTION π¦
so what is this actually giving? it's giving a simple numeric attribute that supports most of the basic math operations. that's it, that's the whole thing. she does numbers, she does math, she does it in place. iconic behavior honestly. β
π PROVIDED METHODS π
IMPORTANT NOTE BESTIE: all of these methods do in place modification of the value stored in the attribute. like, they change the actual thing. not a copy. not a vibe. the real one. and also β these methods are implemented within this package. π
add($value)β adds the current value of the attribute to$value. so you're stacking it up, we love an accumulative queen. β¨sub($value)β subtracts$valuefrom the current value of the attribute. taking it away, respectfully. πmul($value)β multiplies the current value of the attribute by$value. exponential growth era. πdiv($value)β divides the current value of the attribute by$value. sharing is caring. π«Άmod($value)β returns the current value of the attribute modulo$value. the remainder, the leftovers, the little bit nobody talks about but she's still there. πabsβ sets the current value of the attribute to its absolute value. negative thoughts? gone. only positivity now. periodt. πΈ
π§ METHODS π§
these ones are just vibing here, no description given, just names, and we respect that:
metamethod_provider_classhelper_type
π SEE ALSO π
MouseX::NativeTraitsβ go read her too, she's the whole family. π
and that's the page bestie!! this absolute baddie of a manual was served up by perl v5.34.0, dated 2022-06-16, under the MouseX...ts::Num(3pm) banner. go forth and do math, you've got this. πβ¨π¦π
π¦ 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