What is the diferents between these 2 thing?
#1

Hello,
What is the diferents between these 2 thing?

Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{

}
and:
Код:
new idx;
while(idx < MAX_PLAYERS)
{
   idx++;
}
And if there isn't any diferents, what is bether or faster?
Reply
#2

Both are the same. But i preffer the for loop over while
Reply
#3

Quote:
Originally Posted by dice7
Both are the same. But i preffer the for loop over while
They are exactly the same thing except that while has no initializer or incremental step. while reduces to a special case of for.
Reply
#4

Same thing.
Reply
#5

Thank you guys! but which one do you prefer? i mean which is the fastest?
Reply
#6

The code is functionally equivalent. The speed difference between these would be negligible, if you are seeking speed improvements I suggest you read some of the popular optimization threads. They can point you in the right direction.
Reply
#7

The "for" will make the script much more readable
Reply
#8

Quote:
Originally Posted by ¤- Lorrden -¤
The "for" will make the script much more readable
It depend what you are doing. And yes i confirm there is no speed difference.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)