Swift - Optionals
Identify the error in this code snippet:
class House {
var owner: String?
}
var house: House? = House()
print(house.owner?.count)class House {
var owner: String?
}
var house: House? = House()
print(house.owner?.count)house is optional, so house.owner needs optional chaining as house?.owner.owner is optional String, so to access count, optional chaining is needed: house?.owner?.count.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions