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…


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 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.


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-15T02:59:12+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 ,<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 ]. 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 . 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: ]
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/ |

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.