标签: scala
Functional Programming in Scala遍历并构建Option类型。它显示了orElse方法:
Option
orElse
def orElse[B >: A](ob: => Option[B]): Option[B]
正如本书所解释的那样:The B >: A says that the B type parameter must be a supertype of A.
The B >: A says that the B type parameter must be a supertype of A.
为什么有必要,orElse的参数化类型是A的超类型?
A
答案 0 :(得分:3)
除了它被多次询问之外,Scala中的FP在GitHub上也有一个很棒的wiki,这部分或者Else方法,explained的详细信息。