Experiments in Overloading – DEV Community

Let’s play with overloading a bit. A easy class: package deal Native::Overloaded { use Moo; has quantity => ( is => ‘ro’ ); use overload ‘0+’ => sub { my $self = shift; return $self->quantity; }; } Enter fullscreen mode Exit fullscreen mode And let’s take a look at it: use Test2::V0; my $obj = […]