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 …


This content originally appeared on DEV Community and was authored by Davmi Jose Valdez Ogando

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]


This content originally appeared on DEV Community and was authored by Davmi Jose Valdez Ogando


Print Share Comment Cite Upload Translate Updates
APA

Davmi Jose Valdez Ogando | Sciencx (2022-04-02T15:11:40+00:00) 100 Days of Swift – Day 3. Retrieved from https://www.scien.cx/2022/04/02/100-days-of-swift-day-3/

MLA
" » 100 Days of Swift – Day 3." Davmi Jose Valdez Ogando | Sciencx - Saturday April 2, 2022, https://www.scien.cx/2022/04/02/100-days-of-swift-day-3/
HARVARD
Davmi Jose Valdez Ogando | Sciencx Saturday April 2, 2022 » 100 Days of Swift – Day 3., viewed ,<https://www.scien.cx/2022/04/02/100-days-of-swift-day-3/>
VANCOUVER
Davmi Jose Valdez Ogando | Sciencx - » 100 Days of Swift – Day 3. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/02/100-days-of-swift-day-3/
CHICAGO
" » 100 Days of Swift – Day 3." Davmi Jose Valdez Ogando | Sciencx - Accessed . https://www.scien.cx/2022/04/02/100-days-of-swift-day-3/
IEEE
" » 100 Days of Swift – Day 3." Davmi Jose Valdez Ogando | Sciencx [Online]. Available: https://www.scien.cx/2022/04/02/100-days-of-swift-day-3/. [Accessed: ]
rf:citation
» 100 Days of Swift – Day 3 | Davmi Jose Valdez Ogando | Sciencx | https://www.scien.cx/2022/04/02/100-days-of-swift-day-3/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.