Skip to content

Instantly share code, notes, and snippets.

@riccjohn
Created November 20, 2019 17:52
Show Gist options
  • Save riccjohn/87dd9b4e2df2b9c79fb5c7b7e5e2ef7d to your computer and use it in GitHub Desktop.
Save riccjohn/87dd9b4e2df2b9c79fb5c7b7e5e2ef7d to your computer and use it in GitHub Desktop.
class Animal {
func eat() {
print("nom nom nom")
}
}
class Dog: Animal {
func bark() {
print("woof!")
}
}
class Cat: Animal {
func meow() {
print("meow!")
}
}
let Quinn = Dog()
Quinn.bark() // "woof!"
Quinn.eat() // "nom nom nom"
let Riccardo = Cat()
Riccardo.meow() // "meow!"
Riccardo.eat() // "nom nom nom"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment