Auto-translated
I discovered a rather minor, but strange quirk regarding loops iterating over array elements. I usually try to use the standard Lua tool for this, like this:
for i, element in table do. So, as an example, I sketched out a code that prints all elements of a table in order: test_table = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
for i, el in test_table do
print('i = ', i, ', el = ', el)
end. The console outputs the following: i = 13, el = 13
i = 1, el = 1
i = 2, el = 2
i = 3, el = 3
i = 4, el = 4
i = 5, el = 5
i = 6, el = 6
i = 7, el = 7
i = 8, el = 8
i = 9, el = 9
i = 10, el = 10
i = 11, el = 11
i = 12, el = 12. That is, the 13th element comes first, and then all the others in order. And the most interesting thing is that this manifests ONLY when the array size is 13 elements; everything else I tested with a larger or smaller size iterated normally, starting from the 1st element. This is a Lua feature. I encountered this in code where the order of iteration was important.
