Supported forEachIndexed
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.forEachIndexed{}'"
|
||||
fun foo(list: List<String>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val s1 = s.substring(1)
|
||||
println(s1.hashCode() * index)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.forEachIndexed{}'"
|
||||
fun foo(list: List<String>) {
|
||||
list
|
||||
.map { it.substring(1) }
|
||||
.forEachIndexed { index, s1 -> println(s1.hashCode() * index) }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'forEachIndexed{}'"
|
||||
fun foo(list: List<String>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
println(s.hashCode() * index)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'forEachIndexed{}'"
|
||||
fun foo(list: List<String>) {
|
||||
list.forEachIndexed { index, s -> println(s.hashCode() * index) }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexed{}.forEach{}'"
|
||||
fun foo(list: List<String>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val x = s.length * index
|
||||
println(x)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexed{}.forEach{}'"
|
||||
fun foo(list: List<String>) {
|
||||
list
|
||||
.mapIndexed { index, s -> s.length * index }
|
||||
.forEach { println(it) }
|
||||
}
|
||||
Reference in New Issue
Block a user