Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Created March 14, 2020 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magdamiu/7fb60c1b7cfa4f4e3008088a355e7e23 to your computer and use it in GitHub Desktop.
Save magdamiu/7fb60c1b7cfa4f4e3008088a355e7e23 to your computer and use it in GitHub Desktop.
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