Daily iOS
Swift

Protocol extension dispatch

What does this code print?

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())

Pick one

Submit