Sure, we have EachIn. EachIn iterates through a list. But EachIn returns the object that each link in the list points to.
Each would not take this extra step. It would simply return the next link in the list.
Why is EachIn bad?
If I am iterating through a list, and I want to remove an element from the list, with EachIn, I don't get a pointer to the current link. So I have no way to delete it directly.
The only option in such a loop is to use ListRemove. But listremove actually has to iterate through the list to find the link that points to the object in question. And what if you should have the same object in the list more than once? Then it will fail.
The only alternative to this is to use a While loop instead.
And let's face it, if we didn't care about having to go through the two extra steps we need to to set up and maintain a while loop, we wouldn't even have EACHIN.
Also, EachIn is fairly useless as is. I'm surprised it's stuck around this long. I mean how often to you make a list and then iterate through it and NOT need to delete elements in the list? Most lists I use are for dynamic objects, like particles, or enemies, or powerups, or bullets, or what have you, and all those things need a condition to check to see if it is time to free them from the list.
Each would not take this extra step. It would simply return the next link in the list.
Why is EachIn bad?
If I am iterating through a list, and I want to remove an element from the list, with EachIn, I don't get a pointer to the current link. So I have no way to delete it directly.
The only option in such a loop is to use ListRemove. But listremove actually has to iterate through the list to find the link that points to the object in question. And what if you should have the same object in the list more than once? Then it will fail.
The only alternative to this is to use a While loop instead.
And let's face it, if we didn't care about having to go through the two extra steps we need to to set up and maintain a while loop, we wouldn't even have EACHIN.
Also, EachIn is fairly useless as is. I'm surprised it's stuck around this long. I mean how often to you make a list and then iterate through it and NOT need to delete elements in the list? Most lists I use are for dynamic objects, like particles, or enemies, or powerups, or bullets, or what have you, and all those things need a condition to check to see if it is time to free them from the list.