Thread: [Solved] loop entitys
View Single Post
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-16-2022 , 23:20   Re: loop entitys
Reply With Quote #28

tl;dr

Quote:
Originally Posted by MrPickles View Post
nop, u are wrong, the loop doesnt count from 0 to 100, look:

if this is my array:
PHP Code:
{2,4,6,100
the loop do this:

PHP Code:
     // i        i++
Array[0] = // i = 0
Array[1] = // i = 1
Array[2] = // 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
PHP Code:
100 
, 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.
__________________
fysiks is offline