Skip to content
lazy var
s are actually stored properties, so you can’t put it in extensions or anywhere stored properties are not allowed.
- The getter for computed properties is run every time you refer to that property. This can be significant especially if the getter is time-consuming or has side-effects to other parts of the code.
- The getter for
lazy var
s are only run when the property is first referred to and never again.
lazy var
s are variables. You can mutate them.
- Computed properties can optionally have a setter, so sometimes they are read-only.
- Using a function like that is very similar to a read only computed property. You just have to add
()
when getting its value.