How can i resolve 'val cannot be reassigned' in kotlin?

In Kotlin, variables declared with `val` are read-only and cannot be reassigned. This error occurs when trying to modify them.

Example:


val number: Int = 10
number = 20

Solution:


var number: Int = 10
number = 20
If you need a mutable variable, use `var` instead of `val`.

Beginner's Guide to Kotlin