http://qs321.pair.com?node_id=633927


in reply to Re^5: self-feeding infinite loop
in thread self-feeding infinite loop

The point wasn't about indexes being numbers or not...
Yes, I understood that you had missed this essential point. That was why I tried to bring it to your attention.

it was that modifying an array while iterating over it is dangerous
As I tried to suggest in my original message, it isn't dangerous. Sorry this wasn't clear to you.

I understand that you fear this construction because you don't understand it, and that you have a faulty mental model of the way foreach loops are processed, which leads you to an incorrect expectation of what they will do when the underlying array is modified. However, this fear is only your private emotion. It is real, but it does not extend outside of yourself. In particular, you cannot conclude from the fact of your fear that the practice is actually "dangerous".