Skip to content

Instantly share code, notes, and snippets.

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