Is there a valid reason to try casting a List to a...
# announcements
j
Is there a valid reason to try casting a List to a MutableList? If I choose to return a List from a method, isn't it clear that the list is not mutable and shouldn't be modified? Regarding the platform types, couldn't we just define a wrapping factory function:
fun <T> unmodifiableList(list: List<T>): List<T> = Collections.unmodifiableList(list)
? Note that I(m not saying Jayson's immutable collections are a bad idea. I'm just trying to understand the differences, pros and cons of the approaches.