I’ve come to the realisation that you cant actually decrement a for loop in Haxe. What is your preferred method of working around this crazy deficiency?
This is one way
for (i in 0...10)
{
trace(Math.abs(i - 10));
}
EDIT: Math.abs returns a Float, so it might need to be converted to an Int
Std.int(Math.abs(i - 10));
Not sure how much weight this adds if you have a big loop. Another way is to make a count var and decrement it.
var count = 10;
for (i in 0...10)
{
trace(count);
count--;
}
Also
var i = 10;
while (i-- > 0) {
trace (i);
}
Thanks guys. These are very helpful.
Someone once joked that “–>” is the “converges to” operator.
Also, I made two different libraries that could help. I don’t use the former much nowadays, and I don’t use the latter at all, but I’m fairly sure they both still work.