scala PartialFunction
1、orElse和andThen的区别
源码如下,区别很明显,orElse是并列的关系,而andThen是调用者的结果作为k的输入。
trait PartialFunction[-A, +B] extends (A => B) { ......}
def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]): PartialFunction[A1, B1] =
new OrElse[A1, B1] (this, that)
override def andThen[C](k: B => C): PartialFunction[A, C] =
new AndThen[A, B, C] (this, k)