What happens when I remove an array element isnide a for loop?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rogerdv

I have that doubt since some time ago. If I remove element number 3, in the next loop iteration, element number 4 is still there or it became 3 when I removed the previous one? Whats the correct way to iterate through an array and remove one or more elements?

:bust_in_silhouette: Reply From: Magso

Don’t loop through the array you’re removing from, create another array that specifies which elements to remove and loop through that array instead.
For example if you have an array of PackedScenes and you want to remove elements 2, 3 & 5, create a new array with the integers 2, 3, 5 and for loop through that array using it’s values to remove from the PackedScene array.