Click or drag to resize

ACloneT Function (Array OfT)

Duplicate a multidimensional array.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION AClone<T>(
	aSource AS ARRAY OF<T>
)
WHERE T : NEW()
 AS ARRAY OF<T>
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#
LOCAL aOne, aTwo AS ARRAY
aOne := {1, 2, 3}                        // aOne is {1, 2, 3}
aTwo := AClone(aOne)                        // aTwo is {1, 2, 3}
aOne[1] := 99                                // aOne is {99, 2, 3}
                                                // but aTwo is still {1,2,3}
See Also