|
|
|
|
|
by jorgemf
3321 days ago
|
|
You can have immutability by making the setters methods of a class private. So if you combine it with "val" you have immutable objects. It is a bit more job in kotlin but as it is also object oriented programming you can achieve exactly what you want. And for structures you have list, mutablelist, map, mutablemap, etc. What else do you want? |
|
According to this http://stackoverflow.com/questions/33727657/kotlin-and-immut... Kotlin does not support true immutability.
For immutability to be practical one would need to implement structural sharing in their collections otherwise copying would be prohibitively expensive.
This Java library seems to be trying to implement this. http://www.vavr.io/
Again, I am not saying that Kotlin does not support immutability, just trying to get to the bottom of the reality of it.