Indirect Enums and Recursive Structures
Building linked lists and trees with indirect enum cases.
Welcome
An `indirect` enum case stores its associated value behind a pointer, enabling recursive data structures like linked lists, trees, and expression trees.
Why indirect is Needed
Without `indirect`, an enum that references itself would have infinite size:
```swift
enum List {
case empty
case node(T, List) // ❌ recursive without size bound
}
```
`indirect` adds a heap allocation so the size is just a pointer.
All lessons in this course
- Raw Values and CaseIterable
- Associated Values for Rich Data
- Indirect Enums and Recursive Structures
- Modeling State Machines with Enums