How to easy set size of multi dimentional dynamic array?

Zarathustra adam.chrapkowski at gmail.com
Wed Sep 3 04:28:47 PDT 2008


Denis Koroskin Wrote:

> On Wed, 03 Sep 2008 13:45:12 +0400, Zarathustra  
> <adam.chrapkowski at gmail.com> wrote:
> 
> > How to easy set size of multi dimentional dynamic array?
> >
> > for example:
> > class Foo{
> >   private double[][] m_array;
> >
> >   this(uint o_length, uint o_width){
> >     // hard way:
> >     this.m_data.length = o_length;
> >     for(uint i = 0; i < this.m_array.length; i++){
> >       this.m_array[i] = new double[o_width];
> >     }
> >   }
> > }
> 
> 
> Try this:
> 
> this(uint o_length, uint o_width){
>    m_array = new double[][](o_length, o_width);
> }

Great, ;)
Thanks Denis


More information about the Digitalmars-d-learn mailing list