DEV Community

Cover image for #100DaysOfSwift: Day 8

Posted on

#100DaysOfSwift: Day 8

Hey !

Today, I learned about structures but for short struct. They are given their own variables, constants, and their own functions and are used in any way. Variables inside of struct are called stored properties and computed properties. You can use a struct when you have fixed data that you want to send or receive multiple times.
I learned about all that goes into structs, like the following:

  1. Computed properties run code to figure out the structs value.

  2. Property observers which lets you run code before or after any property changes.

  3. Methods are functions inside of structs and the functions can use the properties of the struct as needed. Methods belong to structs, enums, and classes.

  4. Mutating methods - the keyword mutating is used when you want to change properties in a struct. By default, structs are constants.

  5. Strings and arrays have their own properties and methods !

Overall, I think today was a good learning day.

Until tomorrow !

Discussion (0)