code as follows, can't access the "contents" var in the struct (see line 37). what am i doing wrong? thank you!
Code Block import Cocoa class Food { var name: String init?(name: String) { if name.isEmpty { return nil } self.name = name } } class Fruit : Food { var color: String init?(name: String, color: String) { self.color = color super.init(name: name) } } struct Bowl { var contents: Fruit? var quantity: Int } var toast = Food(name: "toast") var banana = Fruit(name: "banana", color: "yellow") var myFruitBowl = Bowl(contents: banana, quantity: 5) print(toast?.name as Any) //works print(banana?.color as Any) //works print(myFruitBowl.contents?.color as Any) //works print(myFruitBowl.quantity as Any) //even this works! print(myFruitBowl.contents as Any) // log: Optional(__lldb_expr_25.Fruit)