3 ms·
That's not really accurate either. val foo: Object will always return the same reference, but the state of the referenced object may have been mutated, which
by kod 9y ago
That's not really accurate either.
val foo: Object
will always return the same reference, but the state of the referenced object may have been mutated, which isn't what I'd expect when you say "always immutable, really".
- the_af 9y agoIt's subtle, but you're both saying different things. What happens with Kotlin cannot happen with Scala `val`s. Note in Kotlin it may return something entirely different, not just the same reference to a mutable object. It seems that in Kotlin a `val` may get evaluated every time it's called, whereas in Scala it can only be evaluated once. In Scala it cannot happen that you call a `val` twice and it returns a different object.