Supported forEach
This commit is contained in:
@@ -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()) {
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(list: List<String?>): String? {
|
||||
list
|
||||
.filter { it == null || it.isNotEmpty() }
|
||||
.forEach { return it }
|
||||
return ""
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
+10
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user