KT-14336 for to stdlib to takeWhile: propose conversion into takeWhile if break is located in else branch

#KT-14336 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-10-17 19:14:19 +03:00
parent 5c8db294df
commit 18f10860df
9 changed files with 125 additions and 8 deletions
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'takeWhile{}'"
// IS_APPLICABLE_2: false
fun foo(n: Int, list: List<Int>): List<Int>{
val result = mutableListOf<Int>()
<caret>for (i in list) {
if (i < n)
break
else
result.add(i)
}
return result
}