As outlined in the Declaration section of this document, dynamic-array variables are declared no differently than any other VTS variable. This similarity carries over to assignment, where assigning a value to (or from) a dynamic-array variable is no different than assigning a value to (or from) any other VTS variable. Dynamic-array variables can be assigned any scalar value, including another dynamic-array variable (a pointer to an array). The following code demonstrates these assignments.
If 1 Main;
[
ADynamicArray = 5; { a scalar assignment }
ADynamicArray = New(3, 2); { a new dynamic array }
BDynamicArray = ADynamicArray[1];
{under-specified— ADynamicArray[1][0] is
assigned instead }
BDynamicArray = "super"; { another scalar assignment }
CDynamicArray = New(10); { a new dynamic array }
DDynamicArray = CDynamicArray; { one dynamic array to another }
SimpleVar = DDynamicArray; {a dynamic array to a simple variable }
]
When a dynamic-array variable is assigned to another variable, as in the last two assignments of the previous example, only the pointer is assigned, and no arrays are copied: in the previous example, CDynamicArray, DDynamicArray, and SimpleVar all point to the same dynamically allocated ten-element array.
Note than during these assignments, neither of VTS's automatic array-related features was invoked: no [] index operators were present and none of the array references were under-specified.