https://kotlinlang.org logo
#announcements
Title
# announcements
i

ilya.gorbunov

03/16/2017, 1:44 PM
📣 📣 📣 We have published v0.1 of Kotlin immutable collections library https://discuss.kotlinlang.org/t/kotlinx-collections-immutable-v0-1-has-been-published/2403/2
🎉 7
n

nhaarman

03/16/2017, 9:11 PM
ilya.gorbunov: I'm just curious, what is insufficient about the current 'immutable' collections in the std library? I know you can just cast them to Mutable*, but other than that?
i

ilya.gorbunov

03/16/2017, 9:12 PM
First, they are not immutable — just read-only
n

nhaarman

03/16/2017, 9:22 PM
And second? I mean, the List interface is 'immutable' as long as you don't cast it right?
That's just a bit of discipline
i

ilya.gorbunov

03/16/2017, 9:44 PM
No, it's not about casting. As long as you get
List
as a parameter, you can not reason about whether it's mutable or not. You know it's read-only, but that's all you know. So if you want it not to be changed from the outside, you have to make defensive copy.
2 Views