Prevent Ambiguity – Parenthesize All Expressions

When the expression is evaluated, what will the value of x be? Is it 50 (9 times 6 is 54, minus 4 is 50), or 18 (6 minus 4 is 2, times 9 is 18)? The value is actually 50, but as you can see, order of evaluation makes a big difference. For this reason you should always use parenthesize to explicitly define the order of evaluation. If you had wanted the 9*6 evaluated first you should code , and if you wanted the 6-2 evaluated first you should code . Parenthesize are always evaluated first, and this will prevent any ambiguity. (Applies to: ColdFusion All)

Leave a Reply