On Tuesday, January 23, 2024 12:32:31 PM MST Stephen Tashiro via Digitalmars- d-learn wrote: > On Tuesday, 23 January 2024 at 18:23:22 UTC, Renato wrote: > > This works , your mistake was to not actually assign the array > > to the class' field! > > > > Change this line: > > > > ```d > > auto array = new Point[][](the_dimension,the_dimension); > > ``` > > > > To this: > > > > ```d > > this.array = new Point[][](the_dimension,the_dimension); > > ``` > > Thank you. > > I don't really understand what the syntax > > new Point[][](the_dimension,the_dimension); > > denotes. Does it represent a function? To look up this topic, > what are the proper keywords? > > By experimentation, I found that "new > Point[the_dimension][the_dimension];" doesn't compile.
Except for the first dimension, all subsequent dimensions have to go in the parens, since putting them between the brackets indicates that that dimension is for a static array rather than a dynamic array, so it would change the type of the array (allowing for dynamic arrays of static arrays). As it is, you can probably only put the first dimension between the brackets, because other languages do that, and allowing it makes it easier to port code. Arguably though, for consistency, you should always put the dimensions between the parens when allocating a new dynamic array. - Jonathan M Davis