Daily iOS
0일 연속
Swift 언어객관식

프로토콜 익스텐션 디스패치

다음 코드의 출력은?

protocol Greeter { func hello() -> String }
extension Greeter {
    func hello() -> String { "proto hello" }
    func bye() -> String { "proto bye" }
}
struct Bot: Greeter {
    func hello() -> String { "bot hello" }; func bye() -> String { "bot bye" }
}
let g: any Greeter = Bot()
print(g.hello(), g.bye())

하나만 선택