Just a random example using Zydeco...
use Zydeco prefix => 'App';
class Car {
has name ( type => Str );
has price ( type => Num );
has speed (
type => Num,
default => 0,
handles_via => 'Number',
handles => {
speed_up => 'add',
slow_down => 'sub',
},
);
my $count;
method BUILD { ++$count }
method DEMOLISH { --$count }
method count { $count }
}
my $red_car = App->new_car( name => 'Red' );
my $blue_car = App->new_car( name => 'Blue' );
$red_car->speed_up( 25 );
$red_car->speed_up( 10 );
say $red_car->speed;
say App::Car->count;