-
-
Save Pasanpr/bd5070cc65f7f5a66a990ed8aa459687 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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