Slide 54
Slide 54 text
Native Delegation
✦ Native arrays have push,
pop, shift and unshift
✦ Here we take push and
shift, and build proxy
methods for them
automatically by moose
✦ Can use $q->add_item and
$q->next_item
has 'q' => (
is => 'ro',
isa => 'ArrayRef[Int]',
default => sub { [] },
traits => [qw/Array/],
handles => {
add_item => 'push',
next_item => 'shift',
},
);
package main;
my $q = Queue->new;
$q->add_item(10, 20);
Thursday, December 29, 2011