in reply to Re: Assigning to an ArrayRef accessor type
in thread Assigning to a ArrayRef accessor type
An alternative to this:
my $strings = $mock->files;
Would be this:
my @strings = @{ $mock->files };
Or if you've got a very recent version of Perl:
my @strings = $mock->files->@*;
Moose also has an optional feature where it can detect if an accessor is called in a list context and return a list instead of a reference, but Moo didn't implement that because it can get confusing to work with.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Assigning to an ArrayRef accessor type
by tomred (Acolyte) on Sep 22, 2020 at 10:59 UTC |