www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - document error

http://www.digitalmars.com/d/arrays.html

section: Static Initialization of Static Arrays

enum Color { red, blue, green };
int value[Color.max] = [ blue:6, green:2, red:5 ];

It should be:

enum Color { red, blue, green };
int value[Color.max + 1] = [ Color.blue:6, Color.green:2, Color.red:5 ];

Otherwise:

Error: too many initializers 3 for array[2]


Actually I do hope enum.max === (element count in enum); instead of (the max
value, i.e. the value of the last number).
Sep 07 2005