1 Answers
Differences between val
and var
keywords in Scala
One of the key differences between val
and var
in Scala is that:
val
: Declares an immutable variable whose value cannot be changed once assigned.var
: Declares a mutable variable whose value can be changed after assignment.
It is generally recommended to use val
whenever possible in Scala to promote immutability and functional programming practices.
Please login or Register to submit your answer