100 Days of Swift – Day 8 (and 9)

Continuation of Hacking With Swift 100 Days of Swift

Day 8 (and 9) – Structs

In swift structs are the most commonly used data type. Almost everything is a struct from integers to strings.

To declare a struct it is done like this: struct Person { var…

Continuation of Hacking With Swift 100 Days of Swift

Day 8 (and 9) – Structs

In swift structs are the most commonly used data type. Almost everything is a struct from integers to strings.

To declare a struct it is done like this: struct Person { var name: String} and initialize it we can do it this way: var person = Person(name: "Davmi)".

Structs the same way they contain properties, can have calculated properties, and not only that but methods and even static members too. What is more surprising is that you can even have access modifiers for structs, this makes me want to wonder what are the differences between a struct and a class?.

The most important thing one can find in a struct is the observables didSet and willSet these 2 will trigger themselves as when either a property has changed or a property will change, in my opinion these are the best features of the language.


Print Share Comment Cite Upload Translate
APA
Davmi Jose Valdez Ogando | Sciencx (2024-03-28T17:59:01+00:00) » 100 Days of Swift – Day 8 (and 9). Retrieved from https://www.scien.cx/2022/04/15/100-days-of-swift-day-8-and-9/.
MLA
" » 100 Days of Swift – Day 8 (and 9)." Davmi Jose Valdez Ogando | Sciencx - Friday April 15, 2022, https://www.scien.cx/2022/04/15/100-days-of-swift-day-8-and-9/
HARVARD
Davmi Jose Valdez Ogando | Sciencx Friday April 15, 2022 » 100 Days of Swift – Day 8 (and 9)., viewed 2024-03-28T17:59:01+00:00,<https://www.scien.cx/2022/04/15/100-days-of-swift-day-8-and-9/>
VANCOUVER
Davmi Jose Valdez Ogando | Sciencx - » 100 Days of Swift – Day 8 (and 9). [Internet]. [Accessed 2024-03-28T17:59:01+00:00]. Available from: https://www.scien.cx/2022/04/15/100-days-of-swift-day-8-and-9/
CHICAGO
" » 100 Days of Swift – Day 8 (and 9)." Davmi Jose Valdez Ogando | Sciencx - Accessed 2024-03-28T17:59:01+00:00. https://www.scien.cx/2022/04/15/100-days-of-swift-day-8-and-9/
IEEE
" » 100 Days of Swift – Day 8 (and 9)." Davmi Jose Valdez Ogando | Sciencx [Online]. Available: https://www.scien.cx/2022/04/15/100-days-of-swift-day-8-and-9/. [Accessed: 2024-03-28T17:59:01+00:00]
rf:citation
» 100 Days of Swift – Day 8 (and 9) | Davmi Jose Valdez Ogando | Sciencx | https://www.scien.cx/2022/04/15/100-days-of-swift-day-8-and-9/ | 2024-03-28T17:59:01+00:00
https://github.com/addpipe/simple-recorderjs-demo