Core concept
val x = 42 // immutable
var y = 0 // mutableAdvertisement
How it works
var still allows internal mutation of referenced object. Immutable data structures paired with val for full immutability.
Advertisement
Trade-offs + gotchas
Nearly always val. var only when clearly needed (perf, local mutable accumulators).