Hello tobyinc.
So, I forgot '+' and used subtypes.
package KeyAtom; use Moose; use Moose::Util::TypeConstraints; subtype 'typeKeyAtom', as 'Str | RegexpRef'; has 'data' => ( is => 'rw', isa => 'typeKeyAtom', ); package ValAtom; use Moose; use Moose::Util::TypeConstraints; extends 'KeyAtom'; subtype 'typeValAtom', as 'typeKeyAtom | ArrayRef | HashRef'; #has 'data' => ( #oh my... has '+data' => ( is => 'rw', #re declare isa => 'typeValAtom', ); no Moose; ###test package main; use Data::Dumper; my $test= ValAtom->new(); for ("test str", qr("^test"), [qw/a b c/], {a=>'b',b=>'c'}, sub{'test' +} ){ $test->data($_); print Dumper $test->data; }
In reply to Re^2: Moose "unions" and inheritance
by remiah
in thread Moose "unions" and inheritance
by PetaMem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |