January 2011
Intermediate to advanced
1648 pages
70h 30m
English
Operators also have a precedence relative to one another. The use of parentheses can be used to circumvent those precedence rules. It’s often clearer to add some gratuitous pairs of parentheses than to assume every reader of the code is intimately familiar with the precedence of operators used in an expression.
Everyone knows examples from high school mathematics:
a + b * c
The preceding evaluates b times c before carrying out the addition with a. Adding parentheses—here really redundant as every self-respecting developer should know those basic math rules, at least in my opinion—makes this ordering explicit:
a + (b * c)
Obviously, if you want to multiply the sum of a and b with c, precedence needs to be overridden ...
Read now
Unlock full access