Skip to content

Instantly share code, notes, and snippets.

@Pasanpr
Created February 6, 2017 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pasanpr/bd5070cc65f7f5a66a990ed8aa459687 to your computer and use it in GitHub Desktop.
Save Pasanpr/bd5070cc65f7f5a66a990ed8aa459687 to your computer and use it in GitHub Desktop.
protocol Animal {
associatedtype Food
func eat(_ food: Food)
}
struct Kibble {}
class Cat: Animal {
func eat(_ food: Kibble) {
// code
}
}
struct DogFood {}
class Dog: Animal {
func eat(_ food: DogFood) {
//
}
}
let cat = Cat()
let dog = Dog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment