📜  kotlin reduce - Kotlin 代码示例

📅  最后修改于: 2022-03-11 14:53:34.745000             🧑  作者: Mango

代码示例1
listOf(1, 2, 3).reduce { sum, element -> sum + element }    // 6

val strs = listOf("a", "b", "c", "d")
println(strs.reduce { acc, string -> acc + string })         // abcd