tl;dr
Quote:
Originally Posted by MrPickles
nop, u are wrong, the loop doesnt count from 0 to 100, look:
if this is my array: the loop do this:
PHP Code:
// i i++
Array[0] = 2 // i = 0
Array[1] = 4 // i = 1
Array[2] = 6 // i = 2
Array[3] = 100 // i = 3, oops this cell contain 100, so we can stop
thats why the condition,
PHP Code:
__int_Entitys[i] < 100
if it was counting from 0 to 100, it will be , but isnt the case, u can check it by yourself with the prints that i setted
|
Indeed, you are correct, I misread that part. However, it relies on a specific input value that is not actually related to the purpose of the input to prevent the loop from causing the index out of bounds error which isn't really a good design. My method does not require this and will allow you to reliably iterate over the input array regardless of the values contained within the array.
__________________