Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwifttype erasureSingle-choice MCQ

What is the runtime cost difference that makes `any Collection` more expensive than a generic `<C: Collection>` parameter for the same operation?

func sumGeneric<C: Collection>(_ c: C) -> Int where C.Element == Int { c.reduce(0, +) } func sumErased(_ c: any Collection) -> Int { /* harder */ 0 }