You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moises Aguirre edited this page Feb 12, 2024
·
2 revisions
GDCC provides enumerations as an extension to ACS, with a nearly identical syntax to C. Enumerations allow naming integer constants and are particularly useful for sequential constants.
Values are assigned sequentially by default starting from zero. An explicit value can also be assigned.
// The enum name is optional.
enum Fruits
{
APPLE, // First constant is 0 by default.
ORANGE, // Second is 1, and so on.
MELON = 4, // An explicit value can be assigned.
STRAWBERRY, // This constant is 5, following the usual sequential assignment.
PINEAPPLE, // This constant is 6. Trailing commas are also allowed as in C.
}
// The enum name becomes a type name, usable where int/str/fixed/bool would be.
// This behaves identically to an int.
Fruits FavoriteFruit = MELON;