Files
kotlin-fork/idea/testData/intentions/loopToCallChain/sum/indexUsed.kt
T
Valentin Kipyatkov d0f6e25783 sum and sumBy supported
2016-08-23 22:47:42 +03:00

11 lines
287 B
Kotlin
Vendored

// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'mapIndexed{}.sum()'"
// INTENTION_TEXT_2: "Replace with 'asSequence().mapIndexed{}.sum()'"
fun foo(list: List<Int>): Int {
var s = 0
<caret>for ((index, item) in list.withIndex()) {
s += item * index
}
return s
}