I have an Array of values, and I need to cycle through it: next, next, next, and when it is the last element, go back to first.
I thought I found the most elegant solution with Array.get() because it does not break the execution:
currentCastleID += 1
if not castle_lists.keys().get(currentCastleID):
currentCastleID = 0
But it generates the error: Index p_index = 8 is out of bounds (p_instance->size() = 8)
Of course I could check that element's index is equal to the Array size... But this feels not very elegant.
Is there a prettier way, maybe? The problems seems very basic, must be encountered a zillion times already...