mutableListOf
Platform and version requirements: JVM (1.1), JS (1.1), Native (1.1)
fun <T> mutableListOf(): MutableList<T>
Returns an empty new MutableList.
import kotlin.test.*
fun main(args: Array<String>) {
val list = mutableListOf<Int>()
println("list.isEmpty() is ${list.isEmpty()}")
list.addAll(listOf(1, 2, 3))
println(list)
}
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> mutableListOf(vararg elements: T): MutableList<T>
Returns a new MutableList with the given elements.
import kotlin.test.*
fun main(args: Array<String>) {
val list = mutableListOf(1, 2, 3)
println(list)
list += listOf(4, 5)
println(list)
}