Merging val & var

Please, stop saying that. It confuses a lot of other developers. In the examples you give, the vals 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 vals 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.

1 Like