Member-only story
Comparable Enums in Swift 5.3
Enum cases will automatically synthesize the required implementation to conform to the Comparable
protocol in Swift 5.3
1. Group Related Values at Enumeration
Enumeration, or Enum for short, is a popular data type in many languages. It groups related values in a type-safe way within the code.
In Swift, Enumeration adopts many features supported by the first-class type, like struct
, and class
. It has initializers to provide an initial case value. It can be extended to expand functionality. Enum can have computed properties and instance methods to provide additional information. It also can implement protocol
to align the behavior.
Enumeration is introduced with a pair of braces with the enum
keyword.