Pattern Matching
object Main extends App {
def matchTest(x: Any): Any = x match {
case 1 => "one"
case "two" => 2
case y: Int => "scala.Int"
case true => "true"
case _ => "none"
}
println(matchTest(3.54))
}INFO
object Main extends App {
def matchTest(x: Any): Any = x match {
case 1 => "one"
case "two" => 2
case y: Int => "scala.Int"
case true => "true"
case _ => "none"
}
println(matchTest(3.54))
}