2

I saw a piece of Scala code with manifest syntax as follows. I do not know what WireFormat means here. What constraint does it add to the Manifest A? Does it mean the type A must extends the trait WireFormat?

I could not find any document about such syntax.

trait WireFormat[A] {
  def toWire(x: A, out: DataOutput)
  def fromWire(in: DataInput): A
}

class DList[A : Manifest : WireFormat]
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
zjffdu
  • 25,496
  • 45
  • 109
  • 159

1 Answers1

4

It is a context bound. With two types separated by colons it just means there are two implicit parameters.

In other words it's the same as:

class DList[A](implicit x: Manifest[A], y: WireFormat[A])
Community
  • 1
  • 1
Luigi Plinge
  • 50,650
  • 20
  • 113
  • 180
  • On [context bounds and view bounds](http://stackoverflow.com/questions/4465948/what-are-scala-context-and-view-bounds) is also very handy. – Matt Roberts May 30 '13 at 21:28