Added test and asserts
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
var index2 = 0
|
||||
<caret>for ((index1, s) in list.withIndex()) {
|
||||
if (s.length > index1) continue
|
||||
if (s.length < index2++) continue
|
||||
return s
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.firstOrNull()'"
|
||||
fun foo(list: List<String>): String? {
|
||||
var index2 = 0
|
||||
return list
|
||||
.filterIndexed { index1, s -> s.length <= index1 && s.length >= index2++ }
|
||||
.firstOrNull()
|
||||
}
|
||||
Reference in New Issue
Block a user