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

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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.