start page | rating of books | rating of authors | reviews | copyrights

Book HomeActionScript: The Definitive GuideSearch this book

5.8. The Grouping Operator

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. 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


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.