Hullaballoonatic
05/02/2019, 1:43 AMMutableList::toList
? Is it just basically a toggle or something, or does it have to copy values into a new object? I imagine that perhaps mutable list is a wrapper for list, but i'm not suregildor
05/02/2019, 1:50 AMgildor
05/02/2019, 1:52 AMHullaballoonatic
05/02/2019, 1:52 AMList::toMutableList
, thengildor
05/02/2019, 3:30 AMgildor
05/02/2019, 3:33 AMmarstran
05/02/2019, 7:12 AMto
will copy all the content to a new structure, while methods starting with as
will just create a view over the original structure.Mike
05/02/2019, 10:47 AMList
or return it as a List
from a function so the caller only sees the ‘immutable’ interface. I believe it’s an ArrayList (by default) under the covers regardless, and Kotlin merely relies on the interface to ‘control’ access.Al Warren
05/03/2019, 1:18 AMSomeClass {
private val _myList: MutableList<String>? = null
val myList: List<String>? = _myList
// do things
}
gildor
05/03/2019, 2:31 AM