偏函数 PartialFunction[A, B] A 输入参数类型 B 返回结果类型 val pf01: PartialFunction[Int, String] = { case 1 => "a" case 2 => "b" case _ => "c" } println(pf01(0)) println(pf01(1)) println(pf01(2)) println(pf01(3)) val list = (0 to 7).toList list.map(pf01).foreach(print)