Adding a value to a set

suggest change

To add a value to a Set, use the .add() method:

mySet.add(5);

If the value already exist in the set it will not be added again, as Sets contain unique values.

Note that the .add() method returns the set itself, so you can chain add calls together:

mySet.add(1).add(2).add(3);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents