Raised This Month: $ Target: $400
 0% 

Pawn Tutorial on wiki


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-01-2010 , 01:22   Re: Pawn Tutorial on wiki
Reply With Quote #2

There is no differences, the increment paramater is always done after the code has been executed <- i don't know for that part, but the condition is checked before for sure.

++i or i++ makes no difference in a for loop.

In the following code, difference would be that in function 1 checks starts with i == 2 and in fonction2 checks starts with 1.
So, ++i, i is incremented first and its result is then returned, with i++, i value is returned before it is incremented.
PHP Code:
function1()
{
    new 
1
    
while( ++<= 10 )
    {
        
// 
    
}
}

function2()
{
    new 
1
    
while( i++ <= 10 )
    {
        
// 
    
}


Would have an importance in a for loop if you would do something like :

for(new i=val; ++i < SOME_VALUE; some other check)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-01-2010 at 01:24.
ConnorMcLeod is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode