protocol Chef {
func makeFood()
}
extension Chef {
func makeFood() {
print("make food")
}
}
struct SeafoodChef :Chef{
func makeFood() {
print("cook sea food")
}
}
let chefOne :Chef=SeafoodChef()
let chefTwo :SeafoodChef=SeafoodChef()
chefOne.makeFood()
chefTwo.makeFood()
协议中是动态派发,扩展中是静态派发。即协议Chef中是否声明makeFood方法,结果不一样.