Enumeration

What is an enumeration?

An enumeration is a named set of named integer constants.

An enumeration is what?

Let's take an example:

CREATE ENUM gender_t = {
  NA = -1,
  feminine = 1,
  masculine = 2
}

This creates a named set (the name is "gender_t") of named integer constants (for example, the integer constant "1" is given the name "feminine").

OK, I get it. Any restrictions?

Yes. Both the enumeration name ("gender_t" above) and the enumeration constant names (e.g., "NA", "masculine") must be identifiers.

Also, you can't have two constants with the same value in the same enumeration. It is a set, not only in the names, but also in the values. And the there must exist a one-to-one mapping between the two sets (of names and integer values), so they must also have the same number of elements. In other words, you can't have two constants with the same value, nor can you have two values with the same name. Period.


Previous:Feature
Up:EMdF model
Next:Summary