我想匹配String
返回的someFunction
,并且默认情况下会从String
返回someFunction
。
someFunction(input) match {
case "123" => "234"
case "234" => "345"
case _ => _
}
case _ => _
返回someFunction(input)
实际返回的内容。这可能吗?
答案 0 :(得分:6)
您只需要命名默认情况:
someFunction(input) match {
case "123" => "234"
case "234" => "345"
case x => x
}