On Thursday, 22 March 2018 at 14:05:02 UTC, steven kladitis wrote:
-- what is the difference between int[] x; and int[int] x; ????

int[] x; is like
struct _Int_Array
{
    size_t len;
    int* ptr;
}
_Int_Array y;
int i = 5;
x[i] = i; // this and the line below crash or assert, due to a null pointer
*(y.ptr +i) = 5;
are both the same;

int[int] is a completely different beast. is it a hashtable that maps ints to int.
its a lot closer to int[string] than it is to int[]

see https://dlang.org/spec/arrays.html vs https://dlang.org/spec/hash-map.html

Reply via email to