When accessing an element outside a dynamic array I get an exception.

I thought in D arrays will automatically expand themselves?

If not, how do I add an element to an array?

int[] arr = new int[1];
arr[1] = 34; // exception

If I change this to

int[] arr = new int[2];
arr[1] = 34;

Then it works. (similar to C/C++)

But my arrays will be growing and I do not know the final size ahead of time.

arr.add(34) does not work.


Reply via email to