Supported other patterns for mapNotNull
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>for ((index, s) in list.withIndex()) {
|
||||
val length = s?.substring(index)?.length
|
||||
if (length == null) continue
|
||||
target.add(length.toString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapIndexedNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.mapIndexedNotNull { index, s -> s?.substring(index)?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>for (s in list) {
|
||||
val length = s?.length
|
||||
if (length == null) continue
|
||||
target.add(length.toString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapNotNull{}.mapTo(){}'"
|
||||
fun foo(list: List<String?>, target: MutableList<String>) {
|
||||
<caret>list
|
||||
.mapNotNull { it?.length }
|
||||
.mapTo(target) { it.toString() }
|
||||
}
|
||||
Reference in New Issue
Block a user