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

In protocol-oriented programming, you provide a default method in a protocol extension AND a different implementation in a conforming type, but you call it through the protocol type. Which implementation runs in the snippet below?

protocol P {} extension P { func greet() { print("default") } } struct S: P { func greet() { print("custom") } } let p: P = S() p.greet()