Completed Day 3 of 100 days of SwiftUI today (https://www.hackingwithswift.com/100/swiftui). The focus today was operators and conditions.
It’s very similar to BASIC at the moment - although you can see how the language has advanced to make it easier to read and shorter.
Eg.
score -= 5
Rather than typing:
score = score - 5
Summarising
Swift has operators for doing arithmetic and for comparison.
There are compound variants of arithmetic operators that modify their variables in place: +=, -=, and so on.
You can use if, else, and else if to run code based on the result of a condition.
Swift has a ternary operator that combines a check with true and false code blocks.
If you have multiple conditions using the same value, it’s often clearer to use switch instead.
You can make ranges using ..< and ... depending on whether the last number should be excluded or included.