Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mutable and immutable set
// immutable set and mutable set
val colors = setOf("red", "blue", "yellow", "white")
var miniColors = listOf("red", "blue")
var result = colors.containsAll(miniColors)
println(result)
val mutableColors = mutableSetOf("red", "blue", "yellow")
mutableColors.add("pink")
var mutableSetIteratorColors = mutableColors.iterator()
while (mutableSetIteratorColors.hasNext()) {
print(mutableSetIteratorColors.next())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment