Skip to content

Instantly share code, notes, and snippets.

@Edudjr
Last active March 24, 2021 06:06
Show Gist options
  • Save Edudjr/fecea5ac46517c4866a68e0c2284ae8a to your computer and use it in GitHub Desktop.
Save Edudjr/fecea5ac46517c4866a68e0c2284ae8a to your computer and use it in GitHub Desktop.
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