Initial support for "+=", filterTo and mapTo for collections

This commit is contained in:
Valentin Kipyatkov
2016-04-06 15:40:33 +03:00
parent ac46684592
commit 22fb397662
13 changed files with 177 additions and 19 deletions
@@ -0,0 +1,6 @@
// WITH_RUNTIME
fun foo(list: List<String>, target: MutableList<String>) {
<caret>for (s in list) {
target.add(s)
}
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(list: List<String>, target: MutableList<String>) {
<caret>target += list
}
+7
View File
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun foo(list: List<String>, target: MutableList<String>) {
<caret>for (s in list) {
if (s.length > 0)
target.add(s)
}
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(list: List<String>, target: MutableList<String>) {
list.filterTo(target) { it.length > 0 }
}
+7
View File
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun foo(list: List<String>, target: MutableList<Int>) {
<caret>for (s in list) {
if (s.length > 0)
target.add(s.hashCode())
}
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
fun foo(list: List<String>, target: MutableList<Int>) {
<caret>list
.filter { it.length > 0 }
.mapTo(target) { it.hashCode() }
}