In Swift, protocols with associated types differ fundamentally from generics: associated types allow implementers to choose the concrete type when conforming to the protocol, while generics allow callers to specify the type at the call site. This distinction is crucial because Swift requires associated types to be explicitly declared in the protocol or an inherited protocol, and developers often confuse these two mechanisms when designing protocol-based architectures.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
the protocol error every swift dev hits #programmingAdded:
Swift doesn't let you do this.
It says "No dice."
You try to create this protocol and it'll say, "Hey, an associated type named T must be declared in the protocol or in a protocol it inherits." Now, most developers, we try to write code like this and run into this problem. The implementer is providing the type, whereas a generic, like in this case with this generic syntax here, a generic says, "Hey, the caller gets to decide the type."
That's the fundamental difference.
Generics are for the callers to implement and associated types are for the implementers to choose. My take is they're both a variable. It's just who gets to decide what that variable ends up being, the caller or the implementer.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 viewsβ’2026-05-28
How agent o11y differs from traditional o11y β Phil Hetzel, Braintrust
aiDotEngineer
450 viewsβ’2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanationπ―β
LearnwithSahera
1K viewsβ’2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 viewsβ’2026-05-29
Search Algorithms Explained in 60 Seconds! π€π¨
samarthtuliofficial
218 viewsβ’2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 viewsβ’2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 viewsβ’2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 viewsβ’2026-06-01











