Variables (val / var)
Immutable values with val, mutable values with var; type inference and naming.
Simple enough for a 5-year-old to understand
val: immutable value
In Scala, values defined with val cannot be reassigned. In a functional style, val is preferred first.
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)