kotlin basics : Using Set in the code - devrath/KotlinAlchemy GitHub Wiki
About Set
- 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
and process
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
or remove the element
from the set
only if we use mutableSet()
, This is similar to other collections.
private fun initiate() {
var students = setOf("Mahesh","Suresh","Venkatesh","Mahesh")
println(students)
println(students.contains("Suresh"))
}