In the following code, why is the property of bacon.name equal to "[Unnamed]" if class RecipeIngredient overrides init(name:) and does not make a call to class Food's init() initializer? I'm having trouble tracing the flow of this code. Can anyone explain this to me?
class Food {
var name: String
init(name: String) {
self.name = name
}
convenience init() {
self.init(name: "[Unnamed]")
}
}
class RecipeIngredient: Food {
var quantity: Int
init(name: String, quantity: Int) {
self.quantity = quantity
super.init(name: name)
}
override convenience init(name: String) {
self.init(name: name, quantity: 1)
}
}
let bacon = RecipeIngredient()
print(bacon.name)
// prints "[Unnamed]"
print(bacon.quantity)
// prints "1"