Overview - Var for mutable references
What is it?
In Kotlin, 'var' is a keyword used to declare variables whose values can change after they are first set. Unlike 'val', which creates a read-only reference, 'var' allows you to update the variable to point to a different value or object. This means you can reassign new data to a 'var' variable anytime during the program.
Why it matters
Without mutable references like 'var', programs would be very limited because you couldn't change data once set, making it hard to handle real-world situations where information changes over time. 'var' lets you write flexible and dynamic code that can respond to user input, calculations, or other changing conditions.
Where it fits
Before learning about 'var', you should understand basic Kotlin syntax and the difference between variables and constants. After mastering 'var', you can explore deeper topics like data mutability, object references, and Kotlin's type system.