What is an 'associated type' used for in Swift?

iOS interview question for Intermediate practice.

Answer

To declare a placeholder type name within a protocol definition.

Explanation

Associated types act as placeholders for specific types within a protocol. They are defined within the protocol's definition, not inside functions (A). They're not about nested types (C) or generic constraints (D), but about defining a type relationship within the protocol itself.

Related Questions