Simple array init question

Craig Black cblack at ara.com
Mon Apr 9 10:37:32 PDT 2007


Graham, I was wondering if you were someone that I know.  Are you the Graham 
I am thinking of?

-Craig

"Graham" <grahamamacdonald at gmail.com> wrote in message 
news:ev7kdm$1p8e$1 at digitalmars.com...
> Why will array setting work for a 1D array, but not a 2D?  If I enter:
>   int[5] buffer;
>   buffer[] = 5;
>
> It compiles, but if I enter:
>   int[5][5] buffer;
>   buffer[][] = 5;
>
> (I tried the variation buffer[] = 5, but that didn't work either.)
>
> It fails to compile (in gdc), with the warning:
>
>   MainLoop.d:56: Error: cannot implicitly convert expression (5) of type 
> int to int[5]
>   Error: cannot cast int to int[5]
>   make: *** [build/MainLoop.o] Error 1
>
> To my untrained eye, it looks like it would like me to pass it an int[5] 
> to initialize the array, but that's a bit odd - I'd much rather treat it 
> similarly to a 1D array in this case!
>
> Thanks,
> graham 





More information about the Digitalmars-d mailing list