October 24, 2003 Request: Dynamic array initialization | ||||
---|---|---|---|---|
| ||||
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]); |
October 24, 2003 Re: Request: Dynamic array initialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Patrick Down | >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]); |
Copyright © 1999-2021 by the D Language Foundation