Created
March 14, 2020 14:13
-
-
Save magdamiu/7fb60c1b7cfa4f4e3008088a355e7e23 to your computer and use it in GitHub Desktop.
Mutable and immutable set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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