www.digitalmars.com         C & C++   DMDScript  

D - basic array resizing

Call me a BASIC-loving fool but what's wrong with the syntax:

float[] a;
dim a[4];
for (i : a[i])
  a[i] += 5;
dim a[7]; // larger... so zero-fills (default initializes) the new ones
for (i : a[i])
  a[i] += 2;
for (i : a[i])
  print a[i] ' '; // prints 7777222

Sean
Oct 03 2002