ACloneShallowT Function (Array OfT) | |
Duplicate an array without its subarrays.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION ACloneShallow<T>(
aSource AS ARRAY OF<T>
)
AS ARRAY OF<T>
public static Array Of<T> ACloneShallow<T>(
Array Of<T> aSource
)
Request Example
View SourceParameters
- 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 without its subarrays.
Remarks
ACloneShallow() creates a duplicate of aSource.
Unlike AClone(), ACloneShallow() does not check to see if aSource contains subarrays and does not copy them if they exist.
ACloneShallow() also works differently from AClone() in that AClone() duplicates by recursively traversing the source array.
ACloneShallow() first builds the target array structure from information derived directly from the source array, then copies the first-dimension values to the target.
If an element of the source array is a subarray, the target array will contain a reference to the subarray.
Examples
This example creates an array and duplicates it using ACloneShallow().
Moreover, by changing an element in the source subarray that automatically affects the target subarray, it
illustrates that subarrays are copied by reference:
1LOCAL aSource, aTarget, aSourceSubArray AS ARRAY
2aSourceSubArray := {3,4,5}
3aSource := {1, 2, aSourceSubArray}
4aTarget := ACloneShallow(aSource)
5
6
7aSourceSubArray[3] := 100
8
9
See Also