www.digitalmars.com         C & C++   DMDScript  

D - Request: Dynamic array initialization

reply Patrick Down <pat codemoon.com> writes:
I would like to be able to do dynamic array initialization.

For example:

int a = 2;
int b = 3;

int[] b = [ 3, 4, a, b];

or

void func(int[] arr) { }

func([ 3, 4, a, b]);
Oct 23 2003
parent "Charles Sanders" <sanders-consulting comcast.net> writes:
or

void func(int[] arr) { }

func([ 3, 4, a, b]);
That would be cool. This code compiles for me on dmd .74. --- import c.stdio; int a [] = [1,2,0xa,0xb]; int [] b = [2,3,5,8]; void main () { foreach ( int x ; a ) { printf("x = %d\n",x); } puts("\n"); foreach ( int x ; b ) { printf("x = %d\n",x); } } "Patrick Down" <pat codemoon.com> wrote in message news:Xns941DE515ECA35patcodemooncom 63.105.9.61...
 I would like to be able to do dynamic array initialization.

 For example:

 int a = 2;
 int b = 3;

 int[] b = [ 3, 4, a, b];

 or

 void func(int[] arr) { }

 func([ 3, 4, a, b]);
Oct 23 2003