in reply to Moose type constraint failure
It works for me. The module:
And calling it:use Modern::Perl; package Testing; use Bit::Vector; use Moose; has 'thing' => ( isa => 'Bit::Vector', is => 'rw', default => sub { return Bit::Vector->new(32); }, ); no Moose; __PACKAGE__->meta->make_immutable; 1;
output:use Modern::Perl; use Testing; use Data::Dump qw/dump/; my $object = Testing->new; say dump($object);
To reproduce your error, I have to initialize the object as follows:bless({ thing => bless(do{\(my $o = 39557684)}, "Bit::Vector") }, "Tes +ting")
my $object = Testing->new({thing => undef});
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
In Section
Seekers of Perl Wisdom