tjohnn
08/01/2019, 10:51 AMMutableList.map{ ... }
to return MutableList
instead of List
Mark Murphy
08/01/2019, 10:55 AMmapTo()
instead of `map()`: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/map-to.htmlMark Murphy
08/01/2019, 10:58 AMfun main() {
val original = mutableListOf(1, 2, 3)
val mapTarget = mutableListOf<String>()
original.mapTo(mapTarget) { (it * it).toString() }
println(mapTarget)
}
diesieben07
08/01/2019, 11:00 AMval target = original.mapTo(mutableListOf()) { ... }
tjohnn
08/01/2019, 11:04 AM