Skip to content

Instantly share code, notes, and snippets.

@meidikawardana
Created December 28, 2020 03:48
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 meidikawardana/89a3e5ce23683adffbed671a2d5a556e to your computer and use it in GitHub Desktop.
Save meidikawardana/89a3e5ce23683adffbed671a2d5a556e to your computer and use it in GitHub Desktop.
fun main() {
val numbers = listOf(0, 3, 8, 4, 0, 5, 5, 8, 9, 2)
println("list: ${numbers}")
println("sorted: ${numbers.sorted()}")
val setOfNumbers = numbers.toSet()
println("set: ${setOfNumbers}")
val set1 = setOf(1,2,3)
val set2 = mutableSetOf(3,2,1)
println("$set1 == $set2: ${set1 == set2}")
println("contains 7: ${setOfNumbers.contains(7)}")
val peopleAges = mutableMapOf<String, Int>(
"Fred" to 30,
"Ann" to 23
)
peopleAges.put("Barbara", 42)
peopleAges["Joe"] = 51
// add key value with key the same as with one of existing keys
// will update the existing key's value
peopleAges["Fred"] = 31
println(peopleAges)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment