CArray:Empty
The Empty method deletes all members of the CArray but does not delete the CArray object.
CArray:Empty() |
This deletes all array members without deleting the CArray object itself. If you delete the CArray, the object is set to nil and cannot be used again without creating a new instance using new. By calling Empty, the existing CArray can be used to Set new members, and so forth.
The following script fragment sets 3 members in a new CArray M, then deletes all members of M:
A = CArray:new() |
-- create a CArray |
A:Set( 127, -63.25 ) |
-- set member |
A:Set( 100, 12.34 ) |
-- set member |
A:Set( 4, -42 ) |
-- set member |
Printf("Members = %d", A:Count() ) |
-- result: Members = 3 |
A:Empty() |
-- empty the array |
Printf("Members = %d", A:Count() ) |
-- result: Members = 0 |
A:delete() |
-- if finished with A, clean up memory |