How to initialise array of ubytes?

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 29 12:22:38 PST 2014


Paul:

> I'm trying to do this:
>
> ubyte[MAPSIZE][MAPSIZE] map = 1;
>
> but it doesn't work and I can't seem to cast the value to a 
> ubyte (which looks rather ugly and out of place in D anyway). 
> Is there a way to do this other than using a couple of loops?

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?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list