PDA

View Full Version : for....loop Bug


MapAnalysis
10-26-2006, 04:23 PM
I tried this:

var i:int;
for (i = 0; i < 5; i++) {

Alert.show(i.toString());


}

And received 4,3,2,1

This is standard stuff guys:

Workaround to get what I wanted ie 1,2,3,4

var i:int;
for (i = 5; i > 0; i--) {

Alert.show(i.toString());


}

Tink
10-26-2006, 05:53 PM
huh?

for ( var i:int = 0; i < 5; i++)
{
trace( i );
}will output 0, 1, 2, 3, 4

for ( var i:int = 5; i > 0; i00)
{
trace( i );
}will output 5, 4, 3, 2, 1

Alerts open on top of each other. Theres no bug here.

newblack
10-31-2006, 05:33 PM
lolz

jsebrech
11-02-2006, 06:44 AM
Whenever you suspect the development tool has a bug, assume you're wrong and it doesn't. It is extremely rare that it happens, and it's almost never in basic syntax. (Last time I ran across a dev tool bug was in the memory allocation routines of an older version of Delphi, which were sensitive to fragmentation in the right conditions.)