Comment by 1899-12-30
2 years ago
One really nice thing about object pascal(and nim I think) is that you can declare enums as array indexes.
type
TMonth = (mJan = 1, etc);
TFooPerMonth = array[TMonth] of integer;
2 years ago
One really nice thing about object pascal(and nim I think) is that you can declare enums as array indexes.
type
TMonth = (mJan = 1, etc);
TFooPerMonth = array[TMonth] of integer;
That is a great feature.
You can have those semantics in .net, because any hashable can be a dictionary key. It will have a small performance penalty, which won't matter in 99% of cases. You could roll your own collection and get O(1).
F# lets enum values be records, which is the most elegant solution IMO for manageable counts and fields.