struct Developer {
let name: String
}
struct Company {
let name: String
var developer: Developer?
}
var company = Company(name: "NKLKB", developer: nil)
company.developer
var developer = Developer(name: "Kim Sang Woo")
company.developer = developer
print(company.developer)
print(company.developer?.name)
print(company.developer!.name)
if let result = company.developer?.name {
print("if let")
print(result)
}
else {
print("nil")
}
func optionalBinding(result: Any?) {
guard let result = company.developer?.name else {
print("nil")
return
}
print("guard let")
print(result)
}
optionalBinding(result: company.developer?.name)