下一个代码是正确的,但我不明白 为什么"()"关闭后需要, if"() - >"在输入之前丢失了吗?
class Person {
var name: String
/*lazy var personalizedGreeting: ()->String = {
[unowned self] in
return "Hello, \(self.name)!"
}*/
lazy var personalizedGreeting: String = {
[unowned self] in
return "Hello, \(self.name)!"
}()
init(name: String) {
self.name = name
}
}
let person = Person(name: "John Doe")
print(person.personalizedGreeting)