This is NOT a computed property.
let navigationController: UINavigationController = {
var navigator = UINavigationController()
navigator.navigationBar.translucent = false
return navigator
}()
This is just a stored property , populated with the result of the value returned by this block of code.
var navigator = UINavigationController()
navigator.navigationBar.translucent = false
return navigator
A block is executed when an instance of the class is created. Just one time.
So, I am writing this
struct Person {
let name: String = {
let name = "Bob"
return name
}()
}
struct Person {
let name: String
init() {
self.name = "Bob"
}
}
IMHO , :
# 1:
, (). , .
, () , - , .
Swift stored closure. , UINavigationController.
.
struct Person {
let sayHello: ()->() = { print("Hello") }
}
sayHello, . 0 Void.
let bob = Person()
bob.sayHello
bob.sayHello()
# 2:
, , a Computed Property.
, , , a Computed Property , .
age. , , .
(age)
