Enum Properties

Section • 2 episodes • 55 min

Although structs and enums have first class treatment in Swift and are awesome to use, structs tend to have nicer ergonomics than enums. We will explore what it would look like for enums to get many of the affordances that structs have.

Related content

These supplemental episodes use SwiftSyntax to build a code generation tool for enum properties, eliminating the burden of having to hand-roll them.

Swift Syntax Enum Properties
23 min
Advanced Swift Syntax Enum Properties
31 min
Swift Syntax Command Line Tool
35 min

In this episode we compare structs and enums in a more abstract way: using algebra!

Algebraic Data Types
36 min

Where to go from here

We’ve now seen how we can take a feature of structs, properties in particular, explore the equivalent API on enums, and find benefits, like more ergonomic data access. It’s time to take things to the next level by taking another, related feature of structs, key paths, and make a case for the enum equivalent.