An instance of the class Set (a set) is a collection of objects, in which no two elements are equal. Most of its methods are inherited from Collection. The contents of a set are unordered; therefore, code must not rely on the order of elements in a set. For an ordered variant, see OrderedIdentitySet; for multisets (i.e., sets in which distinct elements can be equal, but that remain unordered), see Bag.
nil as an element. Attempting to add nil will result in a runtime error: ERROR: A set cannot contain nil.
This restriction exists because nil is internally used as a sentinel value to represent unoccupied slots in hash-based collections. As a result, this limitation also applies to Set’s subclasses.
Add an Object to the Set. An object which is equal to an object already in the Set will not be added.
Remove an Object from the Set. Element is checked for equality (not for identity).
Returns true if the specified item is present in the Set. Elements are checked for equality (not for identity).
Returns the item, if it is present in the set. Otherwise returns nil. Element is checked for equality (not for identity).
Evaluates function for each item in the Set. The function is passed two arguments, the item and an integer index.
Returns the object at the internal index. This index is not deterministic.
Return the set theoretical intersection of this and that. The function will search for objects occurring in both sets and return a new set containing those. Elements are checked for equality (not for identity).
Return the set theoretical union of this and that. The function combines the two sets into one without duplicates. Elements are checked for equality (not for identity).
Return the set of all items which are elements of this, but not of that. Elements are checked for equality (not for identity).
Return the set of all items which are not elements of both this and that. Elements are checked for equality (not for identity).
Returns true if all elements of this are also elements of that. Elements are checked for equality (not for identity). Since Set is an unordered collection, order doesn't matter in this comparison.