Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSwiftstatic vs dynamic witness dispatchSingle-choice MCQ

Given the protocol and extension below, what does this program print, and what governs each line's dispatch?

protocol Greeter { func hello() -> String // a protocol requirement } extension Greeter { func hello() -> String { "default hello" } func bye() -> String { "default bye" } // NOT a requirement } struct G: Greeter { func hello() -> String { "G hello" } func bye() -> String { "G bye" } } let g: Greeter = G() print(g.hello()) print(g.bye())