#35: Operator Precedence
Question
// Swift Quiz
— objc.io (@objcio) October 23, 2019
let number = 3
let result = 1+2 * number-1
// What’s the value of result?
Solution
Solution: 6
— objc.io (@objcio) October 24, 2019
Despite the confusing spaces, Swift has a clearly defined operator precedence. This gets parsed as 1 + (2*number) - 1.https://t.co/s7500CWmAg