Array initializers and inheritance

Frank Benoit (keinfarbton) benoit at tionex.removethispart.de
Sun Oct 29 04:45:27 PST 2006


I think, the array initialization feature is not so nice. The array
takes its type from the type of the first initializer. This is
absolutely ugly.

I would prefer if you can write this
_gameObjects = new GameObject [ new Player(), new Target(Direction.Up,
0, 0)];

The second bad thing is, they tend to generate static arrays. So often
you need to append a [] to convert the static array into a dynamic one.

When generating D code, i use array initialization and cast every member
to the type of the array element and append [] to every such
initializer. This code looks really ugly.

@W Please rethink this syntax :)

Or did I really missed the "good way of array initialization"?







More information about the Digitalmars-d-learn mailing list