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?
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?
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.
SwiftMultiple choiceBasics
Which statements about Swift enum are correct? Pick all that apply.
#enum
SwiftShort answerIntro
Why does Swift have optionals?
#enum
SwiftShort answerBasics
Extend Optional so that any optional can be asked for its nil status, like…
#enum
SwiftShort answerAdvanced
Suppose there were no question-mark optional syntax and no standard Optional. If you had…
#enum