D language: initializing dynamic multidimensional array best practices?
Just curious if this is the best practice for initializing a dynamic, multidimensional array in D . There is a section on arrays in their language reference, but I'm not quite sure if it goes over what I'm trying to accomplish. class Map { Tile[][] tiles; this(uint width, uint height) { tiles.length = height; foreach (ref tilerow; tiles) tilerow.length = width; } } Map map1 = new Map(5000, 3000); // values determined at runtime (or an equivalent alternative like a typical for (y=0;y<height;y++) loop). My concern with this is that it reallocates each row of the array separately rather than the