https://developer.apple.com/videos/play/wwdc2022/110352/

<aside> πŸ“Œ λͺ©μ°¨

ν‚€μ›Œλ“œ

Abstraction

Model with concrete type

Identify common capabilities

Build an interface

Write generic code


protocol Animal {
	associatedtype Feed: AnimalFeed
	func eat(_ food: Feed)
}

struct Farm {

	// μ•„λž˜ ν‘œν˜„ λ‘˜λ‹€ κ°€λŠ₯
	func feed<A: Animal>(_ animal: A) { ... } 

	func feed<A>(_ animal: A) where A: Animal
}