in reply to Re: [Perl6] Seq iterator already consumed
in thread [Perl6] Seq iterator already consumed
Thanks, choroba. I didn’t know about .^name — that’s useful. I found this explanation under https://docs.perl6.org/language/classtut#Introspection:
The syntax of calling a method with .^ instead of a single dot means that it is actually a method call on its meta class, ...
I’ll have to look into that.
But
say @dirs.^name;returns Array, so it should be OK.
Actually, at this point @dirs contains two Seq objects. I think the subsequent call to split iterates each Seq (which is ok, since a Seq is a one-shot iterable); the later call to map attempts to iterate them again, causing the error.
This explanation would be fine if it weren’t for line C. Since join iterates over the Seq, it should be line C that produces the error. But it isn’t — and, as I stated in the OP, removing line C removes the error at line D too. So, still confused. :-(
But I did find another fix: change line A to this:
my @dirs.push: $_.split('/').cache for @paths; # A'
At least this looks less like a kludge than line B.
Cheers,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: [Perl6] Seq iterator already consumed
by duelafn (Parson) on Jun 17, 2019 at 13:36 UTC | |
by Athanasius (Archbishop) on Jun 19, 2019 at 06:51 UTC | |
by duelafn (Parson) on Jun 20, 2019 at 03:36 UTC |