Saturday, April 17, 2010

Post-decrement and Pre-decrement

What's different between Post-decrement and Pre-decrement?

Check it out!
var num:int=20;
trace("Line2:"+(num--));
trace("Line3:"+num);
trace("Line4:"+--num);
trace("Line5:"+num);

export:
Line2:20
Line3:19
Line4:18
Line5:18

When we use Post-decrement,it will decrease after the expression is evaluated.

No comments:

Post a Comment