Click or drag to resize

ACloneT Function (Array OfT)

X#
Duplicate a multidimensional array.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION AClone<T>(
	aSource AS ARRAY OF<T>
)
 AS ARRAY OF<T>
Request Example View Source

Parameters

aSource
Type: Array OfT
The array to duplicate.

Type Parameters

T
The type of the array elements

Return Value

Type: Array OfT
A duplicate of aSource.
Remarks
AClone() creates a complete duplicate of aSource.
If aSource contains subarrays, AClone() creates matching subarrays and fills them with copies of the values in the aSource subarrays.
To copy subarrays by reference instead of creating new ones, use ACloneShallow().
Examples
This example creates an array, then duplicates it using AClone().
The first array is then altered, but the duplicate copy is unaffected:
X#
1LOCAL aOne, aTwo AS ARRAY
2aOne := {1, 2, 3}            // aOne is {1, 2, 3}
3aTwo := AClone(aOne)            // aTwo is {1, 2, 3}
4aOne[1] := 99                // aOne is {99, 2, 3}
5                        // but aTwo is still {1,2,3}
See Also