Variables · 4 of 42
Variables are declared using the var keyword.
In many cases, the type information can be omitted, thanks to Scala’s type inference.
To declare a variable with explicit type, put the type after the variable name following a colon :
e.g.
var x: Int = 1 + 2
var x = 1 + 2 println(x) x = 3 * 4 println(x)