This course is currently a work in progress. Please join the waitlist to receive regular updates.
Adding elements to a set
To add records into a set, use the set add()
method.
Following is an example of adding string values to a set.
Loading...
In the above example:
- The keyword
Set
is used to declare a Set which can hold string values. - The variable name
names
can be used to operate (add/remove..etc) on the set. - The
names
set contain three values(Adam, Akash). - The
add()
method of the set automatically deduplicates the value 'Adam'.
Try It Yourself
Loading...