DEV Community

Discussion on: Immutable Data Structures

Collapse
 
martinhaeusler profile image
Martin Häusler

Thanks! I'm not familiar with the apple world at all, but from your description it sounds like Kotlin does the same thing - there's Set<T> which is immutable, and MutableSet<T> which extends Set<T> and adds methods such as add(T) and remove(T). In general, I think this is good practice, it works really well in Kotlin and conveys a lot more information than in Java, where you only have one Set<T> interface, and it may or may not be modifiable for you.