Daily iOS
Swift

How Swift enums differ

A colleague who mostly writes Java or C asks whether a Swift enum is just a list of constants in the end. What's fundamentally different about a Swift enum compared with enums in other languages?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

A Swift enum is a sum type: each case can carry different associated values, so it expresses a kind together with the data valid only for that kind, and it's a first-class type with methods, protocol conformance, and extensions.

Share a question