Scala的模式匹配类似Java的条件选择,但scala匹配的类型更多,功能更强
1.值匹配 == Java
-
def matchTest1(x:Int): Any = x match { case x if (60 <= x && x < 99) => "优秀" case 100 => println("你是个人才") case _ => "继续努力吧" }
def matchTest1(x:Int): Any = x match {
case x if (60 <= x && x < 99) => "优秀"
case 100 => println("你是个人才")
case _ => "继续努力吧"
}