projects
/
gitmo/Mouse.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
Add $attr->insertion_order
[gitmo/Mouse.git]
/
example
/
traits.pl
1
#!perl
2
package IntStack;
3
use Mouse;
4
5
has storage => (
6
is => 'ro',
7
isa => 'ArrayRef[Int]',
8
9
default => sub{ [] },
10
traits => [qw(Array)],
11
12
handles => {
13
push => 'push',
14
pop => 'pop',
15
top => [ get => -1 ],
16
},
17
);
18
19
__PACKAGE__->meta->make_immutable();
20
21
package main;
22
23
my $stack = IntStack->new;
24
25
$stack->push(42);
26
$stack->push(27);
27
28
print $stack->pop, "\n";
29
print $stack->top, "\n";
30