0

Here is the method signature example:

someMethod [A <: BaseType : SecondType : ClassTag]

trait BaseType {}

trait SecondType[A] {}

ClassTag is scala.reflect.ClassTag

What does ":" means?

Does BaseType influence to SecondType or/and ClassTag parametrization?

For me when I see [A <: BaseType] I understand that I should call someMethod with type parameter that implements/extends trait BaseType, but what other parameters are used for?

Cherry
  • 31,309
  • 66
  • 224
  • 364
  • 1
    possible duplicate of [What are Scala context and view bounds?](http://stackoverflow.com/questions/4465948/what-are-scala-context-and-view-bounds) – 4e6 Sep 12 '14 at 05:27
  • There are only examples like `(A:a, B,b)`, not likle `(A:a:b:c)`. – Cherry Sep 12 '14 at 05:31
  • 1
    Why are there questions about "what are all the uses of underscore" but not "what are all the uses of colon?" or "dot?" or "dollar?" – som-snytt Sep 12 '14 at 05:43

1 Answers1

8

That's probably obvious to someone, but:

scala> trait X[A] ; trait Y[A]

scala> def f[A : X : Y] = 42

yields

    def f[A](implicit evidence$1: X[A], evidence$2: Y[A]) = 42

under -Xprint:parser. So it wants both X[A] and Y[A].

som-snytt
  • 39,429
  • 2
  • 47
  • 129