Why shouldn't you be able to do this?
Swift enums are first-class types, just like struct
s and class
es. Swift enum
s do not need to have cases, they can be completely empty types, just like how a struct
or class
does not need to have any properties.
enum Empty {} // completely valid
enum
s cannot have _ stored instance properties_, but they can have type properties (which static
properties are) and computed instance properties.
Caseless enums with static properties are often used for storing constant values. For more information on the topic, see Swift constants struct or enum
This might not be documented in the Enumerations section of the Swift docs, but nothing says that this shouldn't be possible either. On the other hand, the docs do state that enums are first-class types and there is a non-exhaustive list of features that enums share with classes and structs.