2012-01-12 1 views
4

나는 이것이 아마 내 부분에 펄이나 무스의 일부에 대한 기본적인 오해 실현,하지만 난 default 방법에서 ArrayRef를 반환 할 수있을 것 같지 않습니다MooseX :: Attribute 기본 메소드에서 ArrayRef를 반환하려면 어떻게해야합니까?

has '_directories' => (
    is => 'ro', 
    isa => 'ArrayRef[Str]', 
    lazy => 1, 
    init_arg => undef, 
    default => method {return File::Spec->splitdir($self->relativeDirectory)}); 

제공 :

Attribute (_directories) does not pass the type constraint because: 
Validation failed for 'ArrayRef[Str]' with value 3 

어떻게 정렬합니까?

답변

6

splitdir은 arrayref가 아니라 목록을 반환합니다. [] 생성자를 사용하여리스트에서 arrayref를 생성 할 수 있습니다.

default => method {return [ File::Spec->splitdir($self->relativeDirectory) ] }, 
관련 문제