Supported indexOf/lastIndexOf

This commit is contained in:
Valentin Kipyatkov
2016-04-22 22:44:42 +03:00
parent c080ecb0d1
commit c2103e2200
5 changed files with 65 additions and 17 deletions
+10
View File
@@ -0,0 +1,10 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'indexOf()'"
fun foo(list: List<String>): Int {
<caret>for ((index, s) in list.withIndex()) {
if (s == "a") {
return index
}
}
return -1
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'indexOf()'"
fun foo(list: List<String>): Int {
<caret>return list.indexOf("a")
}
+10
View File
@@ -0,0 +1,10 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'lastIndexOf()'"
fun foo(list: List<String>) {
var result = -1
<caret>for ((index, s) in list.withIndex()) {
if (s == "a") {
result = index
}
}
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'lastIndexOf()'"
fun foo(list: List<String>) {
val <caret>result = list.lastIndexOf("a")
}