Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwiftgenerics and constraintsSingle-choice MCQ

Conditional conformance lets a generic type conform to a protocol only when its parameter does. Which line below fails to compile, given this setup?

struct Pair<T> { let a: T; let b: T } extension Pair: Equatable where T: Equatable { static func == (l: Pair, r: Pair) -> Bool { l.a == r.a && l.b == r.b } } let p1 = Pair(a: 1, b: 2) == Pair(a: 1, b: 2) // (1) let p2 = Pair(a: {}, b: {}) == Pair(a: {}, b: {}) // (2), T == () -> Void