On Tuesday, 30 September 2014 at 15:57:58 UTC, Mike James wrote:
Hi,
How do I initialise a dynamic array of dynamic arrays?
struct MyData {
SysTime stamp;
short[] data;
this(size_t size) {
data = new short[size];
}
}
MyDataArray mda;
how to initialise mda?
mda = new MyDataArray ?
Thanks.
Regards, -=mike=-
I think I've found a way...
struct MyData {
SysTime stamp;
short[] data;
this(size_t size) {
data = new short[size];
}
}
MyDataArray[] mda; <--- sorry, missing the []s in the original
question...
so in the constructor...
this(size_t x, size_t y) {
mda = new MyDataArray[](x);
foreach(n, _; mda) mda[n].data.length = y;
}
Is there a simpler way?
Regards, -=mike=-