How to initialise array of ubytes?

Paul via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 29 12:47:08 PST 2014


On Saturday, 29 November 2014 at 20:22:40 UTC, bearophile wrote:
> This works:
>
> enum MAPSIZE = 3;
> void main() {
>     ubyte[MAPSIZE][MAPSIZE] map2 = 1;
> }
>
>
> This doesn't work:
>
> enum MAPSIZE = 3;
> ubyte[MAPSIZE][MAPSIZE] map1 = ubyte(1);
> void main() {}
>
> Why isn't this working?
>

I'm afraid I don't know. I would guess it's something to do with 
trying to initialise the array in the global scope but you've 
also changed the expression in the non-working example. I don't 
have access to my machine at present so I can't experiment!



More information about the Digitalmars-d-learn mailing list