geatmo
09/13/2017, 1:30 PMval myList = List(3) { it }
which, as the documentation states, creates a read-only list.. but as far as I can see, this list only appears to really be read-only, as I am able to do this:
(myList as MutableList).clear()
and the list will get modified..
so for actually immutable lists, should I better stick to keep using listOf()
instead?geatmo
09/13/2017, 1:41 PMclear()
is not working when using listOf()
, something like set()
is.. so I guess I'm stuck with "I gave you a immutable list reference.. please don't try to cast it to being mutable" with both of those methods..karelpeeters
09/13/2017, 5:11 PMCollections.immutableList
.geatmo
09/14/2017, 8:56 AM