Диспетчеризация: что напечатает protocol extension?
Задача
protocol MyProtocol { }
extension MyProtocol {
func method() { print("In Protocol") }
}
struct MyStruct: MyProtocol {
func method() { print("In Struct") }
}
let myStruct = MyStruct()
let myProtocol: MyProtocol = myStruct
myStruct.method()
myProtocol.method()
Продолжение ответа с кодом и уточняющими вопросами интервьюера — в приложении DevPrep.
Полный ответ — в DevPrep