Home »
Code Examples »
Scala Code Examples
Scala - Variables in Matches Code Example
The code for Variables in Matches
import scala.util.Random
// Generate an integer number
val random_number = new Random().nextInt(100)
random_number match {
case 21 => println("Got my luck number.")
case number => println("The number is: " + number)
}
/*
Output:
The number is: 79
*/
Code by IncludeHelp,
on August 7, 2022 17:46