How to get sum of all second element of a List<...
# announcements
z
How to get sum of all second element of a List<Pair<String, Int>>
e
Copy code
fun main() {
    val listPairs = listOf("a" to 1, "b" to 2, "c" to 3)
    println(listPairs.sumBy{ it.second })
}
👍 3
z
Thanks @estevanfick I added one more map before sum
f
No need of another map 🙂