DEV Community

loading...

Discussion on: "for" vs. "forEach" and the value of documentation

Collapse
jakebman profile image
jakebman

This was originally in perldoc. I think it applies very generally if you take out the Perl-specific vocabulary:

(Almost any for or foreach construct) will get very confused if you add or remove elements to (what you're looping over) within the loop. So don't do that.