|
|
|
|
|
by 1718627440
253 days ago
|
|
I mean plain iteration uses function calls. Iterators are a more advanced concept that needs wrapper objects and function calls. > as this is often the sign of a bug. Why? I've just written that yesterday, I had never a problem with that. For example after deleting an element from an array I need to commit this change, by adjusting the size, etc. Why is it so unexpected that I also need to adjust the index? The index needs to be modified anyway. Where is the notion coming from that this is less preferable than the workarounds, like marking some elements for deletion and then iterating a second time or by making a second container and moving everything that shouldn't be deleted (.filter) ? |
|
And sometimes it's a simple bug where you never meant to modify the collection.