Swift Types & FunctionsLesson 23Free preview
Swift Enums & Patterns
This lesson is part of Swift · All levels
Summary
This lesson is about Enumeration in Swift which is very feature-rich compared to Enum in C. The enum in Swift is a first-class type that can have associated values for storing additional information, raw values for primitive data types, computed properties, and member methods.
Key points
- Enum grouping a set of values related to type-safe
- Defined by the keyword 'enum'
- Supporting 'Associated Values' to embed specific data on each case
- Supporting 'Raw Values' with default types such as String or Int
- Very idiomatic combined with the statement 'switch' for pattern matching
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.