in reply to Is it safe to append to the array you are iterating over
i found this very interesting.. it is incredible after more then 10 years using Perl, discover 'new' point of view about some simple as a foreach (@array) loop.
++ to Re: Is it safe to append to the array you are iterating over and Re: Is it safe to append to the array you are iterating over (yes)
I'm happy to see that, once again,Perl is doing it correctly: it is a logical operetion append to a list while iterating over it. Other operations are confusing.
May be worth to add some words to Perldoc: "...get very confused if you add or remove elements within the loop body (unless you merely push something at the end),....".
L*
++ to Re: Is it safe to append to the array you are iterating over and Re: Is it safe to append to the array you are iterating over (yes)
I'm happy to see that, once again,Perl is doing it correctly: it is a logical operetion append to a list while iterating over it. Other operations are confusing.
May be worth to add some words to Perldoc: "...get very confused if you add or remove elements within the loop body (unless you merely push something at the end),....".
L*
there are no rules, there are no thumbs..
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Is it safe to append to the array you are iterating over
by DrWhy (Chaplain) on Mar 15, 2013 at 22:53 UTC |
In Section
Seekers of Perl Wisdom