Supported forEach

This commit is contained in:
Valentin Kipyatkov
2016-05-11 22:43:00 +03:00
parent 394cce8e10
commit f28dca1fd5
10 changed files with 104 additions and 5 deletions
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
fun foo(list: List<String?>): String? {
<caret>for (s in list) {
if (s == null || s.isNotEmpty()) {
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun foo(list: List<String?>): String? {
list
.filter { it == null || it.isNotEmpty() }
.forEach { return it }
return ""
}
+9
View File
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
fun foo(list: List<String>) {
<caret>for (s in list) {
if (s.isNotBlank()) {
println(s)
}
}
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
fun foo(list: List<String>) {
list
.filter { it.isNotBlank() }
.forEach { println(it) }
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
fun foo(list: List<String>) {
<caret>for (s in list) {
println(s)
}
}
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
import java.util.ArrayList
fun foo(list: List<String>): List<Int> {
@@ -0,0 +1,10 @@
// WITH_RUNTIME
import java.util.ArrayList
fun foo(list: List<String>): List<Int> {
val result = ArrayList<Int>()
list
.filter { it.length > result.size }
.forEach { result.add(it.hashCode()) }
return result
}