This accessor could be implemented in two ways. I'm showing this as a read-only accessor because the read-write aspect isn't important for the example.
sub files {
return $_[0]{'files'};
}
# OR
sub files {
return @{ $_[0]{'files'} };
}
(And of course, there's the version that checks wantarray.)
OP's problem is that he assumed Moo did it the second way, when it actually does it the first way. I don't see how learning to write constructors and accessors from scratch would have helped figure out what the issue was.
|