10.10 Lazy Stored Properties
There are several different ways in which a property can be initialized, the most basic being direct assignment as follows:
var myProperty = 10
Alternatively, a property may be assigned a value within the initializer:
class MyClass {
let title: String
init(title: String) {
self.title = title
}
}
For more complex requirements, a property may be initialized using a closure:
class MyClass {
var myProperty: String = {
var result = resourceIntensiveTask()
result = processData(data: result)
return result
}()
.
.
}
Particularly in the case of a complex closure, there is the potential for the initialization to be resource...