iOS Swift Basics Swift Operators Operator Precedence

Al Hughes
Al Hughes
689 Points

Confusion on Operator Precedence

Hello,

I ran into some confusion during the quiz on this video. With operator precedence it states that addition and subtraction would happen after the other operators. To break it down Pasan put parenthesis around the operators that would happen first. In the code challenge there was a question that had addition in parenthesis. Is this a way of overriding operator precedence?

1 Answer

Richard Li
Richard Li
2,462 Points

That is correct. But it doesn't exactly"override" the precedence. Rather, the parenthesis have a higher precedence themselves, so the operations in the parenthesis should happen first.