5.9 The Grouping Operator

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 5.  Operators

Aside from being used in function calls, parentheses ( ) can also be used to group a phrase of code to override the precedence of various operators. (They also enhance legibility, even if they are not required to override the default precedence.) Parentheses are also required in some statements, most notably if statements. Parentheses take the general form:

(expression)

The expression within the parentheses is evaluated and returned. Here are some examples:

if (x =  = y) {                 // Syntactically required for if statement   trace("x and y are equal"); // Required for the function call } (5 + 6) * 7                   // Force a nonstandard order of operation (x >= 100) || (y <= 50)       // Parentheses not required but added for legibility x >= 100 || y <= 50           // No parentheses...a little harder to read
     



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net