Help with multi-dimentional array
Era Scarecrow
rtcvb32 at yahoo.com
Wed Jul 9 14:58:46 PDT 2008
Jarrett Billingsley Wrote:
> "Era Scarecrow" <rtcvb32 at yahoo.com> wrote in message
> news:g538vm$2391$1 at digitalmars.com...
>
> > abc = new xyz[left][right]; //error needs a const
>
> Just a little weirdness. When you write "new xyz[5]" it's actually sugar
> for "new xyz[](5)". Think of it like a class -- "new Type(Params)".
>
> For multidimensional arrays, just write
>
> abc = new xyz[][](left, right);
>
> It does exactly the same as the much more verbose loop. :)
>
Ah i see. I don't remember this being covered in any of the books i was reading, and having to go through several loops not only looks ugly; but invites bugs.
So if i had a 3-dimentional array, i'd assume i'd have to "= new xyz[][][](a,b,c)?" and so on and so forth?
Then, the question comes up next. If i actually pass a parameter to a class's constructor, would it be....
class xyz{
this(x,y,z){} //three dimentional points
}
//make two dimentional array taking a 3-dimentional location
abc = new xyz[][](left, right)(x,y,z); //is this right??
Era
More information about the Digitalmars-d-learn
mailing list