You’ve made it to the end of the seventh part of this series, so let’s summarize:
- You can create your own types using structures, which can have their own properties and methods.
- You can use stored properties or use computed properties to calculate values on the fly.
- If you want to change a property inside a method, you must mark it as
- Initializers are special methods that create structs. You get a memberwise initializer by default, but if you create your own you must give all properties a value.
- Use the
self constant to refer to the current instance of a struct inside a method.
lazy keyword tells Swift to create properties only when they are first used.
- You can share properties and methods across all instances of a struct using the
- Access control lets you restrict what code can use properties and methods.
Learn Swift faster!
Take your Swift learning to the next level: buy the Hacking with Swift e-book and get bonus material to help you learn faster!