The update() method inserts the given element in the set.
Example
update() Syntax
The syntax of the update() method is:
set.update(with: newElement)
Here, set is an object of the Set class.
update() Parameters
The update() method takes one parameter:
newElement- the new element to insert in set
update() Return Value
- The
update()method doesn't return any value. It just updates set.
Example: Swift Set update()
Output
Before: ["Cathy", "Sabby", "Nick"] Updated: ["Katty", "Cathy", "Sabby", "Nick"]