Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwiftassociated typesSingle-choice MCQ

When does Swift fail to infer an associated type, forcing you to add an explicit `typealias`? Consider this protocol and a partial conformance.

protocol Repository { associatedtype Key associatedtype Value func value(for key: Key) -> Value? } struct Cache: Repository { func value(for key: String) -> Int? { nil } }