object Test {
def main(args: Array[String]): Unit = {
val code = 404
val status = code match{
case 200 => "成功"
case 404 => "Not Found"
case 500 => "Server Error"
case _ => "其他原因"
}
println(status)
}
}
结果:
Not Found