multidimensional array

Stewart Gordon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Sep 28 14:33:40 PDT 2014


On 28/09/2014 08:48, ketmar via Digitalmars-d-learn wrote:
> On Sun, 28 Sep 2014 04:24:19 +0000
> Joel via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:
>
>> struct Spot { bool dot; }
>> spots = new Spot[][](800,600);
> btw, does anybody know why i can do `new ubyte[256];` but not
> `new ubyte[256][256];`? hate that.

You can do `new ubyte[256][256]`, if the destination type is a ubyte[256][].  The reason 
is that you are performing an allocation of the form `new T[n]`, which means allocate an 
array of n instances of type T.  In this case, T is ubyte[256], which is a static array type.

Stewart.

-- 
My email address is valid but not my primary mailbox and not checked regularly.  Please 
keep replies on the 'group where everybody may benefit.


More information about the Digitalmars-d-learn mailing list