Variables (val / var)
Holding immutable values with val and mutable values with var; type inference and naming conventions.
Simple enough for a 5-year-old to understand
val: immutable value
You cannot reassign a new value to a value defined with val later. val is preferred first because it is safe.
val name = "Alex"println(name)var: mutable value
var score = 10score = 20println(score)🎯 Exercise & Practice
Test what you've learned — answer, write code, check instantly. (1 left)