我可以像这样用 Moose 声明一个属性:
has 'attr' => (is => 'rw', isa => 'Int', default => 10);
是否可以将此值重置为默认值?
例子:
$obj->attr(5); # sets attr to 5
$obj->_reset_attr;
print $obj->attr; # will print 10
我可以像这样用 Moose 声明一个属性:
has 'attr' => (is => 'rw', isa => 'Int', default => 10);
是否可以将此值重置为默认值?
例子:
$obj->attr(5); # sets attr to 5
$obj->_reset_attr;
print $obj->attr; # will print 10