Please, stop saying that. It confuses a lot of other developers. In the examples you give, the val
s happen to be immutable, but it is not an inherent feature of val
.
val
means: You can read it, but you cannot change it. Somebody else might be able to change its value though, so do not assume that the value will always be the same.
I can understand the confusion about val
s sometimes being mutable and sometimes being immutable, but we should accurately describe things to help everybody understand how Kotlin works, and what it does and does not provide for you.