Dynamic array initialisers
Gide Nwawudu
gide at btinternet.com
Thu Apr 17 08:20:34 PDT 2008
I have the following code, I am attempting to initialise a variable
with a dynamic array. Should the code compile or are lines 6 and 7
just wrong?
test.d
------
import std.stdio;
void main() {
auto numbers1 = [ 1, 2, 3, 4]; // ok, static array int[4]
int[] numbers2 = ([ 1, 2, 3, 4])[]; // ok
auto numbers3 = [ 1, 2, 3, 4][]; // Doesn't compile
int[] numbers4 = [ 1, 2, 3, 4][]; // Doesn't compile
writefln(typeof(numbers1).stringof);
writefln(typeof(numbers2).stringof);
}
C:\>dmd test.d
a.d(6): semicolon expected following auto declaration, not '['
a.d(7): semicolon expected, not '['
Gide
More information about the Digitalmars-d-learn
mailing list