Reputation: 76597
I can easily declare a enumeration and a set.
But sometimes I want to work with only part of the enumeration and I'd like the compiler to check for me if values in the sub-enum and its subset stay within the bounds.
type
TDay = (mon, tue, wen, thu, fri, sat, sun);
TWeekday = (mon..fri); //not allowed;
TDays = set of TDay;
TWeekdays = set of TDay[mon..fri]; //not allowed
Can I declare TWeekday
and TWeekdays
as a derivative of TDay, if so, how?
Funny enough google does not yield anything (for me) on this issue, just plain old sets.
Upvotes: 4
Views: 1000
Reputation: 34909
You've got the wrong syntax for the subrange. Drop the brackets ()
and it will work.
type
TDay = (mon, tue, wen, thu, fri, sat, sun);
TWeekday = mon..fri; // A subrange of TDay
TDays = set of TDay;
TWeekdays = set of TWeekDay;
More about Subrange Types and Sets.
Upvotes: 12