Scala Immutable vs Mutable Variables - chrisbitm/python GitHub Wiki

There are two ways to store arguments. These are either immutable or mutable expressions. You can also use simple mathematical statements to declare them as well. These are declared with val and var.

val x: Byte = 2+2;
var y: Short = 32768 - 1;
val x: Byte = 4;
var y: Short = 32767;
val z = x - y
print(z)
  • The argument stored in x and z is considered immutable. This means that x cannot be changed.
  • The argument stored in y is considered mutable. This means that y can be changed at any time.