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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With