tryAdd

tryAdd(value: MemberType): Boolean abstract, lockReceiver, updating;

The tryAdd method of the Collection class attempts to add the value specified in the value parameter to the collection if it is not already present. It returns true if the value was successfully added; otherwise it returns false.

Member key dictionaries with a no‑duplicates constraint raise exception 1310 (Key already used in this dictionary) when the collection already contains the member key or keys with a different value, because the tryAdd method is attempting to add a different object that conflicts with an existing entry.

2020.0.01 and higher