tezvyn:

Protocols with associated types and opaque types

Source: interviewintermediate

WHAT IT TESTS: generics and type erasure. OUTLINE: a PAT leaves a placeholder type unresolved, so it has no single concrete shape and historically could not be used as a bare existential; opaque types with some let you return one fixed underlying conforming…

WHAT IT TESTS: understanding why associated types break existentials and what tools address it. ANSWER OUTLINE: a PAT declares an associatedtype placeholder resolved per conforming type, so the protocol lacks a single concrete signature; that historically barred using it as a bare type like [MyProtocol] because the compiler cannot fix the associated types. Opaque types with some return one specific hidden conforming type, preserving type identity for the caller. RED FLAG: claiming some lets you store mixed PAT conformers in one array.

Read the original → interview

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Protocols with associated types and opaque types · Tezvyn