Day51 of #100DaysOfCode

#CodeTogether Day 51/100

Unit 3: Navigation

Create a list

fun main() {
val numbers = listOf(0, 3, 8, 4, 0, 5, 5, 8, 9, 2)
println("list: ${numbers}")
println("sorted: ${numbers.sorted()}")
}
list: [0, 3, 8, 4, 0, 5, 5, 8, 9, 2]
sorted: [0, 0, 2, 3, 4, 5, 5, 8, 8, 9]
val setOfNumbers = numbers.toSet()
println("set: ${setOfNumbers}")
list:   [0, 3, 8, 4, 0, 5, 5, 8, 9, 2]
sorted: [0, 0, 2, 3, 4, 5, 5, 8, 8, 9]
set: [0, 3, 8, 4, 5, 9, 2]
val set1 = setOf(1,2,3)
val set2 = mutableSetOf(3,2,1)
println("$set1 == $set2: ${set1 == set2}")
println("contains 7: ${setOfNumbers.contains(7)}")
[1, 2, 3] == [3, 2, 1]: true
contains 7: false
fun main() {
val peopleAges = mutableMapOf<String, Int>(
"Fred" to 30,
"Ann" to 23
)
println(peopleAges)
}
Output:{Fred=30, Ann=23}
peopleAges.put("Barbara", 42)
peopleAges["Joe"] = 51
fun main() {
val peopleAges = mutableMapOf<String, Int>(
"Fred" to 30,
"Ann" to 23
)
peopleAges.put("Barbara", 42)
peopleAges["Joe"] = 51
println(peopleAges)
}
Output:
{Fred=30, Ann=23, Barbara=42, Joe=51}

Today I Learned:

That is all for Day51 ✅

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store