enum-indexed arrays

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 20 13:43:27 PDT 2014


Nordlöw:

> Have anybody thought about adding safe enum-based indexing to 
> builtin arrays? Ada has this.

I'd like this. I'd like even more: a general way to have 
optionally strongly typed array indexes.


>     enum I { a=3,b=4,c=5 }
>     int[I] x = [3,4,5];

In D currently that "int[I]" is an associative array with I index 
and int values. So in another post I have suggested another 
syntax.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list