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]
1
  • 2
    Read it as takes an A such that there's a Manifest and a WireFormat context for A. Apr 1, 2012 at 16:43

1 Answer 1

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])
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.