CSet:Copy
The Copy method duplicates the CSet and returns the new copy.
S = CSet:Copy() where |
S is a new CSet containing the same members as the current one.
This method copies an existing CSet and returns a reference to the new CSet. You cannot copy a CSet or other class object using the trivial statement B = A, as this simply makes the value of B a reference to the object A. In other words, B becomes an alias to A. To get around this, two copy methods are provided by the CSet class:
To create a CSet that is a copy of the current object, use the Copy method. This creates a new CSet B before duplicating the values of the current object. For example,
|
-- CSet A already exists |
To create a new CSet that is a copy of an existing object, use the copy constructor, as in
|
-- CSet A already exists |
Choose the syntax that fits best with your script.
The following fragment duplicates the CSet.
|
-- create a CSet |
|
-- add a string to the set |
|
-- add a string to the set |
|
-- add a string to the set |
|
-- creates a duplicate CSet named T |
|
-- Result: N = 3 |