![]()  | 
CSet:Copy
The Copy method duplicates the CSet and returns the new copy.
| 
 S = CSet:Copy()  | 
    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,
| 
 B = A:Copy()  | 
 -- CSet A already exists  | 
To create a new CSet that is a copy of an existing object, use the copy constructor, as in
| 
 B = CSet:new(A)  | 
 -- CSet A already exists  | 
You can use the copying syntax that fits best with your script.
The following fragment duplicates the CSet.
| 
 S = CSet:new()  | 
 -- create a CSet  | 
| 
 S:Append("First")  | 
 -- add a string to the set  | 
| 
 S:Append("Second")  | 
 -- add a string to the set  | 
| 
 S:Append("Third")  | 
 -- add a string to the set  | 
| 
 T = S:Copy  | 
 -- creates a duplicate CSet named T  | 
| 
 Printf("N= %d", T:Count())  | 
 -- Result: N = 3  |