I'm still trying to grasp the Scala language, so please bear with me and all my questions.
Can I reference an abstract type from one type parameter in the bound for a开发者_如何学Pythonnother? For instance, is there a way in which the following code can be made to work? The essence of what I'm trying to achieve here is that the KEY for the MAP parameter of C should be the SomeType of the parameter T.
trait T1 {
type SomeType;
}
trait MyMap[KEY, VALUE] { ... }
class C {
def m[T <: T1, MAP <: MyMap[T.SomeType, Int]] { ... }
}
You need type projection:
def m[T <: T1, MAP <: MyMap[T#SomeType, Int]]
精彩评论