Fixed size array initialization

psychoticRabbit meagain at meagain.com
Sun Feb 11 01:13:00 UTC 2018


On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote:
>
> I have a large static initialized array, let's say int[155], 
> and I forgot to declare the last element:
>
> int[155] myarray = [
>   a,
>   b,
>   c,
>   ...
>   //forgot to declare the 155th element
> ];


Well, in C.. I can do:

int arr[2] = { [0]=10, [1]=20 };

I cannot work out how to do that in D yet (anyone know??)

In the meantime, I'd suggest doing it this way, as you're more 
likely to see that whether you forgot an element:

int[2] arr;
     {
         arr[0] = 10;
         arr[1] = 20;
     }





More information about the Digitalmars-d-learn mailing list