Scala: Variables Cheat Sheet

Variable Data Types

val or val VariableName : DataType = [Initial Value]

If you do not assign any initial value to a variable, then it is valid as follows

var myVar :Int; 
val myVal :String;

Multiple assignments

val (myVar1: Int, myVar2: String) = Pair(80, "Ahi")

Another way of defining variable:

val (myVar1, myVar2) = Pair(80, "Ahi")

Leave a Reply

Your email address will not be published. Required fields are marked *