Reputation: 8043
I often need to add a "default value" to some third party enumeration types, for example:
TThirdPartyEnum = (
eA,
eB,
eC
);
I would like to define an enumeration type like this:
TMyEnum = (
eA,
eB,
eC,
eDefault
);
I would like to refer to the TThirdPartyEnum
values in order to avoid maintainance of TMyEnum
(Which should be updated each time TThirdPartyEnum
values changes).
I've unsuccessfully tried as follows:
TMyEnum = Low(TThirdPartyEnum)..High(TThirdPartyEnum) + eDefault;
TMyEnum = (
Low(TThirdPartyEnum)..High(TThirdPartyEnum),
eDefault
);
Is there a syntax which the compiler can understand?
Upvotes: 1
Views: 680
Reputation: 612993
You cannot extend a enumerated type.
You will need a different approach to your problem, perhaps by declaring a new enumerated type and writing helper methods to map between them. You can use implicit cast operators of record helpers to make the code more readable, but that may be more complexity than the task justifies.
Upvotes: 4