Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwiftprotocol-oriented programmingSingle-choice MCQ

Given a protocol with a default method implementation in an extension AND a conforming type that provides its own implementation, what determines which version runs when the value is held in a variable typed as the protocol (existential)?

protocol Greeter { func hello() } extension Greeter { func hello() { print("protocol") } func bonus() { print("protocol bonus") } } struct Bob: Greeter { func hello() { print("Bob") } func bonus() { print("Bob bonus") } } let g: Greeter = Bob() g.hello() g.bonus()