Lilly
01/12/2021, 3:52 AMmutableListOf<String>
and pass this to a consuming function, should I convert this list explicitly to List<String>
with toList()
to have this list immutable or is it enough to define the parameter as List<String>
like:
fun consumingList(list: List<String>)
But then I'm asking if it's really an immutable list... I could still cast it to a mutable List again, not?Matt Rea
01/12/2021, 6:19 AMList
just exposes less than MutableList
. And like you mentioned, you can use toList()
or toMutableList()
to convert between themursus
01/12/2021, 5:11 PMLilly
01/13/2021, 4:06 PM