Merging and Adding Functionality to Enum

In this lesson, you will see two advanced features: merging and adding functions to enum.

We'll cover the following

Merging values #

Like interfaces, an enum can be defined in more than one place. You can start defining the enum and later define it again. In the end, all values merge into a single enum. There is one constraint with multiple definitions of a single enum: the first value of every enum must have an explicit value. If an explicit value is defined twice, only the last value will be associated with the enum when using the reverse value to find an enum. Listing the same value twice is not a feature of multiple definitions; a single enumeration definition can have several entries with the same values as well.

Get hands-on with 1400+ tech skills courses.