我看到了一段带有清单语法的Scala代码,如下所示。我不知道WireFormat在这里意味着什么。它对Manifest A有什么限制?这是否意味着类型A必须扩展特征WireFormat?
我找不到任何关于这种语法的文档。
trait WireFormat[A] {
def toWire(x: A, out: DataOutput)
def fromWire(in: DataInput): A
}
class DList[A : Manifest : WireFormat]
答案 0 :(得分:4)
这是context bound。有两种类型用冒号分隔,这意味着有两个隐含参数。
换句话说,它与:
相同class DList[A](implicit x: Manifest[A], y: WireFormat[A])