Reuse/reset dynamic rectangular array?

Steven Schveighoffer schveiguy at gmail.com
Tue May 28 22:53:54 UTC 2019


On 5/28/19 4:58 PM, Robert M. Münch wrote:
> On 2019-05-28 01:52:28 +0000, 9il said:
> 
>> myRectData[] = null;
> 
> :-/ Ok... doesn't look to complicated ;-) Still learning a lot about D...
> 

Keep in mind, this does not reuse the allocated arrays, it simply resets 
them to point at nothing (and will need to be reallocated).

To reset the way you want, you need a loop:

foreach(ref arr; myRectData)
{
    arr.length = 0;
    arr.assumeSafeAppend;
}

-Steve


More information about the Digitalmars-d-learn mailing list