我正在学习Scala,并尝试按照《Scala Cookbook》中的示例:
trait Animal
trait FurryAnimal extends Animal
case class Dog(name:String) extends Animal
case class Cat(name:String) extends Animal
现在我按照以下方式执行:
val x = Array(Dog("Fido"),Cat("Felix"))
它的显示结果为:
x:Array[Product with Serializable with Animal] = Array(Dog(Fido),Cat(Felix))
虽然我知道一个case class是与Product trait混合使用的
我不理解的是:Product with Serializable with Animal
据我所知,Product与模式匹配有关
我已经尝试过谷歌搜索,但没有找到任何内容。请帮忙详细解释概念。
谢谢