The type is specified using isa, and you need lazy => 1 to make sure the default isn't calculated too soon.
use Moose; has 'x' => ( is => 'rw' isa => 'Num', ); has 'y' => ( is => 'rw', isa => 'Num', lazy => 1, default => sub { sqrt($_[0])->x) }, );
In reply to Re^2: Moose and BUILD
by ikegami
in thread Moose and BUILD
by tj_thompson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |