In Swift, we can set a saved property to use closure:
class Test { var prop: String = { return "test" }() }
vs
or make a closed closed closed property:
class Test { lazy var prop: String = { return "test" }() }
In both cases, the code used to get the value for the property runs only once. They seem to be equivalent.
When should a lazy stored property be used compared to a computed property when using closure with it?
source share