Duplicate
From Director Online Wiki
duplicate
| |
---|---|
Type: | method |
Version: | ? |
Language: | Lingo |
Dependencies: | none |
Links/Related | |
List command; for linear lists and property lists. Copies the existing list to a new memory address. Subsequent operations on vNewList will not affect vExistingList.
Also elements of vExistingList that are (list-)references are duplicated. (See example below)
Syntax
vList.duplicate() duplicate(vList)
Examples
vElement = [99,3,3]
vExistingList = [vElement, vElement]
put vExistingList
-- [[99, 3, 3], [99, 3, 3]]
vExistingList[1][1] = 3
put vExistingList
-- [[3, 3, 3], [3, 3, 3]]
-- As expected, both references of vElement changed.
vNewList = duplicate( vExistingList )
put vNewList
-- [[3, 3, 3], [3, 3, 3]]
vNewList[1][1] = 99
put vNewList
-- [[99, 3, 3], [3, 3, 3]]
put vExistingList
-- [[3, 3, 3], [3, 3, 3]]
-- Note that even the two elements of vNewList were duplicated indepently.
See also
- list()