3 ms·
val reference is not immutable. Your val can return new reference every time it's called: val x: String get() = (i++).toString() And JVM just don't have a
by vbezhenar 9y ago
val reference is not immutable. Your val can return new reference every time it's called:
val x: String get() = (i++).toString()
And JVM just don't have any notion about immutable objects, so Kotlin, obviously, don't have them either. You can return some ImmutableList and I'll change it using reflection and laugh at you. Immutability in Java is about conventions and trust.
- jorgemf 9y agoI said Val means read only, not immutable. I never said java have immutability (only for primitive values)