Using Mathematical Operators: prefix and postfix : Arithmetic Operators « Language « Flash / Flex / ActionScript






Using Mathematical Operators: prefix and postfix

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var quantity:Number = 5;
        trace(quantity++);  // Displays: 5
        trace(quantity);    // Displays: 6
        
        var quantity:Number = 5;
        trace(++quantity);  // Displays: 6
        trace(quantity);    // Displays: 6
    }
  }
}

        








Related examples in the same category

1.Arithmetic Operators in Actionscript
2.Assignment Operators
3.myVariable += 6; is the shorthand version of the following: myVariable = myVariable + 6;
4.myVariable *= 6; is the same as: myVariable = myVariable * 6;
5.Modulo (%)
6.Increment (++) and Decrement ( -- )
7.Compound Assignment Operators (+=, -=, *=, /=, and %=): x += 1; is the same as writing x = x + 1;