An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
100 Days of Swift - Day 3
Continuation of Hacking With Swift 100 Days of Swift
Day 3 - Operators and conditions
This day was about operators, most of them (arithmetic, comparison, etc) works about the same the only difference being that parenthesis are not required inside if statements.
For switch statements, break;
is not required / used, so if you want to execute the next condition in another case you need to use the reserved keyword fallthrough
.
Now "range" operators are a bliss for numerical comparisons and array checking, the half-open range ..< or ..> implies that the range is not inclusive ex: 1..<5 is 1,2,3,4. Where the full range operation is inclusive so 1...5 is 1,2,3,4,5.
On the same fashioned way one can print specifics inside an array with this operator, ex:
let rangedArray: [Int] = [1,2,3,4];
print(rangedArray[1...]);
prints:[2, 3, 4]
Original Link: https://dev.to/davjvo/100-days-of-swift-day-3-9b
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To