Search code examples
scalacontext-bound

":" in type parameter


In scala-arm project, I see code like this:

def managed[A : Resource : Manifest](opener : => A) : ManagedResource[A] = new DefaultManagedResource(opener)

Can someone explain the meaning of [A : Resource : Manifest] ?


Solution

  • def managed[A : Resource : Manifest](opener : => A) : ManagedResource[A] = new DefaultManagedResource(opener)
    

    means

    def managed[A](opener : => A)(implicit r: Resource[A], m: Manifest[A]) : ManagedResource[A] = new DefaultManagedResource(opener)
    

    You can look link text 7.4 Context Bounds and View Bounds for more information.