draegtun (owner)

Revisions

gist: 126849 Download_button fork
public
Public Clone URL: git://gist.github.com/126849.git
Point_neo_moose2.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use MooseX::Declare;
 
role DoesNegated {
    method negated { $self->new( x => -$self->x, y => -$self->y ) }
}
 
role DoesTranspose {
    method transpose { $self->new( x => $self->y, y => $self->x ) }
}
 
class Point with DoesNegated with DoesTranspose {
    has x => ( isa => 'Int', is => 'rw' );
    has y => ( isa => 'Int', is => 'rw' );
 
    method inspect { say $self->x . ' @ ' . $self->y }
}