in reply to Re^2: Using ArrayRef data members in Moose
in thread Using ArrayRef data members in Moose

I know this is OLD! But i want to post this example, that works
use MooseX::Declare; ... ... ... has 'error_log' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); ... ... ... method register_error { shift; my $s_message = shift; return unless defined $s_message; $self->error_log->push ($s_message); return $self->error_log->length; }
self->error_log->push does not work until i assign a "default" for the array.

Replies are listed 'Best First'.
Re^4: Using ArrayRef data members in Moose
by stvn (Monsignor) on Feb 19, 2011 at 21:23 UTC
    self->error_log->push does not work until i assign a "default" for the array.

    Actually it won't work then either until you add a use Moose::Autobox as well.

    -stvn