Files
kotlin-fork/idea/testData/intentions/loopToCallChain/firstOrNull_ifAssign_preserveComments.kt
T
2016-08-16 17:38:02 +03:00

11 lines
344 B
Kotlin
Vendored

// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'firstOrNull{}'"
fun foo(list: List<String>) {
var result: String? = null
<caret>for (s in list) { // search for first non-empty string in the list
if (s.length > 0) { // string should be non-empty
result = s // save it into result
break
}
}
}