Skip to content

Instantly share code, notes, and snippets.

@o-nnerb
Created May 7, 2023 14:55
Show Gist options
  • Save o-nnerb/ff925462a163f314cac20a93e8caa676 to your computer and use it in GitHub Desktop.
Save o-nnerb/ff925462a163f314cac20a93e8caa676 to your computer and use it in GitHub Desktop.
class Animal {
func makeNoise() {
print("Unknown animal!")
}
}
class Dog: Animal {
override func makeNoise() {
print("The dog goes woof!")
}
}
class Cat: Animal {
override func makeNoise() {
print("The cat goes meow!")
}
}
class Bird: Animal {
override func makeNoise() {
print("The bird goes tweet!")
}
}
func makeNoise(animal: Animal) {
animal.makeNoise()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment