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

What does this program print, and what is the dispatch mechanism for the `g.describe()` call?

protocol Shape { func area() -> Int } extension Shape { func area() -> Int { 0 } func describe() -> String { "Shape area \(area())" } } struct Square: Shape { func area() -> Int { 9 } func describe() -> String { "Square!" } } let g: Shape = Square() print(g.describe())