0

I'm new to Scala. I tried to search this syntax but I can't find any example because I don't know what this is called.

The class definition looks like this. How do I understand this? I understand the conformance part that type A conforms to type B, but what is C there for?

class Hello[ A <: B : C ]
  extends D.Apply[ InputType, A ] {
    // ...
}
2
  • 3
    The syntax is called context bounds and is just sugar syntax for implicit / given parameters. Commented Aug 17, 2024 at 23:37
  • 1
    As indicated above, it's sugar for an implicit xx: C[A] parameter at the class level. And then you can retrieve it with implicitly[C[A]] (as it has no name) in the body of the class. (Scala 2) Commented Aug 18, 2024 at 6:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.