? Is one more performant/creates less objects or something?
j
jimn
09/20/2019, 4:56 AM
as much as i love map, i hate forEach, but i would probably arrange my code so that foreach works in all but the most necessary cases where the for-loop has a scoping advantage over a lambda
subjectively speaking, the destructuring declaration looks more expression-calculus-like.
fun main() {
val list = listOf('A', 'B', 'C')
for ((index, value) in list.withIndex()) {
println("$index: $value")
}
list.forEachIndexed{index ,value->
println("$index: $value")
}
}