-
Notifications
You must be signed in to change notification settings - Fork 22
kotlin basics : Using Set in the code
Devrath edited this page Dec 24, 2023
·
1 revision
- This is a type of collection that holds only a
unique collection
of items. - Distinctions from other elements are what make it unique.
- We use set to
store
andprocess
the elements. - Processing the elements is done in a loop.
- We can check if the element exists in a
set
. - If we want to add
new element
orremove the element
from theset
only if we usemutableSet()
, This is similar to other collections.
private fun initiate() {
var students = setOf("Mahesh","Suresh","Venkatesh","Mahesh")
println(students)
println(students.contains("Suresh"))
}