Extensions Clone

array array:clone ( )

Returns a new independent static array object that is a deep copy of itself.

Parameters

None.

Return Values

array Copied array object

Error Conditions

If there is not enough available memory in the system to create a copy of the array, this function will signal an error.

Example

-- Create an array
local arr = array.new(10)
 
-- Clone the array
local arr2 = arr:clone()
assert(arr[0] == arr2[0])
 
arr[0] = 5
assert(arr[0] ~= arr2[0])

Copyright 2010 Justin Aquadro