Is there an idiomatic way to create generic mutabl...
# getting-started
g
Is there an idiomatic way to create generic mutable list of nulls? I did in the following way:
Copy code
private fun <T> mutableListOfNulls(size: Int) = (0..<size).map<Int, T?> { null }.toMutableList()
but I guess there should be simpler solution
j
There is MutableList:
Copy code
val list = MutableList<YourType?>(size) { null }
👍 1
g
yay, thanks!