Reuse/reset dynamic rectangular array?
    matheus 
    matheus at gmail.com
       
    Sat May 25 15:01:30 UTC 2019
    
    
  
On Saturday, 25 May 2019 at 14:28:24 UTC, Robert M. Münch wrote:
> How can I reset a rectangualr array without having to loop 
> through it?
>
> int[][] myRectData = new int[][](10,10);
>
> myRectData.length = 0;
> myRectData[].length = 0;		
> myRectData[][].length = 0;	
>
> They all give: slice expression .. is not a modifiable lvalue.
This works form me:
//DMD64 D Compiler 2.072.2
import std.stdio;
void main()
{
     auto arr = new int[][](10,10);
     writeln(arr.length);
     arr.length=0;
     writeln(arr.length);
}
output:
10
0
Matheus.
    
    
More information about the Digitalmars-d-learn
mailing list