ACloneShallow Function (Array) | |
Duplicate an array without its subarrays.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION ACloneShallow(
aSource AS ARRAY
) AS ARRAY
public static Array ACloneShallow(
Array aSource
)
Request Example
View SourceParameters
- aSource
- Type: Array
The array to duplicate.
Return Value
Type:
Array
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