在我看来,像部分函数的{ case … => … }语法至less需要一种case : scala> val pf: PartialFunction[String, String] = { case "a" => "b" } pf: PartialFunction[String,String] = <function1> scala> val pf: PartialFunction[String, String] = { } <console>:5: error: type mismatch; found : Unit required: PartialFunction[String,String] val pf: PartialFunction[String, String] = { } ^ 那么,定义一个“空”的部分函数的最好方法是什么? 有没有比“手动”重写isDefinedAt和apply更好的方法?