Newer Version Available

This content describes an older version of this product. View Latest

Sets of Objects

Sets can contain sObjects among other types of elements.
Sets contain unique elements. Uniqueness of sObjects is determined by comparing the objects’ fields. For example, if you try to add two accounts with the same name to a set, with no other fields set, only one sObject is added to the set.
If you add a description to one of the accounts, it is considered unique and both accounts are added to the set.

If set elements are objects, and these objects change after being added to the collection, they won’t be found anymore when using, for example, the contains or containsAll methods, because of changed field values.

Warning