Simple Moose example
package Shape;
use Moose;
has 'x' => (is => 'rw', isa => 'Int', default => 0);
has 'y' => (is => 'rw', isa => 'Int', default => 0);
sub move_to {
my ($self, $x, $y) = @_;
$self->x($x); $self->y($y);
}
no Moose; 1;
- use Moose imports 'keywords'
- has, extends, with, before, after, around, super, override, inner, augment
- use strict; and use warnings; (mst++)
- Carp::confess and Scalar::Util::blessed
- has declares class attributes
- is => 'rw'
- isa => 'Int'
- default => 0