Mateus Gondim Mateus Gondim - 1 month ago 10
Android Question

Kotlin - Most idiomatic way to convert a List to a MutableList

I have a method(

) that returns a List and I need to convert this result to a MutableList. Currently the best way I can think of doing it is like this:

val contacts: MutableList<Contact> = ArrayList(presenter.getContacts())

Is there a more idiomatic/"less Java" way to do that?


Consider using the toMutableList() function:


It is defined as an extension for Collection<T>.