Inspectopedia
 
2024.3

Local 'var' is never modified and can be declared as 'val'

Warning
New
Last modified: 03 December 2024

Reports local variables declared with the var keyword that are never modified.

Kotlin encourages to declare practically immutable variables using the val keyword, ensuring that their value will never change.

Example:

The quick-fix replaces the var keyword with val: