Last active
March 24, 2021 06:06
-
-
Save Edudjr/fecea5ac46517c4866a68e0c2284ae8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct AnimalReport { | |
let animal: Animal | |
func describe() {...} | |
} | |
struct AnimalSelection { | |
let animals: [Animal] | |
let animalReport: AnimalReport | |
func selectAnimal(_ animal: Animal) {...} | |
} | |
let animals: [Animal] = [ | |
Dog(name: "Doggy", age: 5), | |
Horse(name: "Horsy", age: 7) | |
] | |
let b = AnimalReport(animal: #Animal#) // Which animal?? | |
let a = AnimalSelection(animals: animals, animalReport: b) | |
// Runtime | |
a.selectAnimal(animals[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment