Okay, so I understand what the error means, but I don't understand why it's happening. The problem is at a point where I remove elements in an `Array`

, but I though that the way I was doing wouldn't give me errors. I attach the the function that gives me problems. I highlight the part where the error is with many `#`

(the error happens for many indeces and sizes, since the array is changing and the are some randomness):

```
func _continents_tiles(continentsProportion : float, tries : int = 10, maxContinentDist : int = 50):
# auxilar variable for continent
var continent : PoolVector2Array
# continents 'Array' (output)
var continents : Array = []
# auxiliar proportion between, the while loop is broken when
# 'proportion > continentsProportion'
var proportion : float = 0
# auxilar 'Array' containing the hexagonal distance between the initial tile
# of the continent and the other tiles
var radiusArray : Array
# the maximun distance of the above 'Array'
var radius : int
# warning-ignore:integer_division
var ring : Array = Array(GLOBALS.hex_ring(Vector2.ZERO, self.R/2))
# auxiliar variable
var ringDist : int
var toRemoveFromRing : Array
var initial : Vector2
# set an initial continent
initial = GLOBALS.random_array_element(ring)
ring.remove(ring.find(initial))
# create the continent and add it to the list of continents
continent = GLOBALS.self_avoinding_compact_random_walk(initial, 2*self.R, self.tilesVpositions)
continents.append(continent)
# calculate the biggest radii in the continent
radiusArray = PoolIntArray([])
for i in range(continent.size()):
radiusArray.append(GLOBALS.hex_dist(initial, continent[i]))
radius = radiusArray.max()
# recalculate proportion and tries
proportion = float(GLOBALS.ArrayArray_size(continents))/self.tilesVpositions.size()
tries -= 1
while proportion <= continentsProportion and tries > 0:
# add some distance, or not, to the next continent
radius += self.rng.randi_range(0, maxContinentDist)
# remove ring tiles that are too close
# recalculate ring
toRemoveFromRing = []
#######################################################################
#######################################################################
#######################################################################
#######################################################################
#######################################################################
for i in range(ring.size()):
ringDist = GLOBALS.hex_dist(ring[i], initial)
if ringDist <= radius:
toRemoveFromRing.append(i)
for i in range(toRemoveFromRing.size()): # HERE
ring.remove(toRemoveFromRing[i])
#######################################################################
#######################################################################
#######################################################################
#######################################################################
#######################################################################
if ring.size() == 0:
break
# set next continent
initial = GLOBALS.random_array_element(ring)
ring.remove(ring.find(initial))
# create the continent and add it to the list of continents
continent = GLOBALS.self_avoinding_compact_random_walk(initial, 2*self.R, self.tilesVpositions)
continents.append(continent)
# calculate the biggest radii in the continent
radiusArray = PoolIntArray([])
for i in range(continent.size()):
radiusArray.append(GLOBALS.hex_dist(initial, continent[i]))
radius = radiusArray.max()
# recalculate proportion and tries
proportion = float(GLOBALS.ArrayArray_size(continents))/self.tilesVpositions.size()
tries -= 1
return continents
```