On Thu, 5 Feb 2009, Matthew Persico wrote:
On Thu, Feb 5, 2009 at 9:32 AM, Dave Rolsky <auta...@urth.org> wrote:
This is not right. There's a much simpler way, and it doesn't require
digging into the object's hashref, which is strongly discourage with Moose.
package Foo;
has 'list' =>
( is => 'rw',
isa => 'ArrayRef',
lazy => 1,
default => sub { [] },
clearer => '_clear_list',
);
my $foo = Foo->new();
$foo->list(); # makes a new arrayref and returns it
$foo->_clear_list;
$foo->list(); # makes a new arrayref and returns it, again
Hmm. But you still have to write _clear_list(), yes?
No, Moose creates it for you.
-dave
/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/