Possible Duplicate:
Why does one select Scala type members with a hash instead of a dot?
I sometimes see a type parameter like:
class Test[K] {
type T = Foo[K#Bar]
}
Can someone please explain what the '#' means in this type parameter ? Is it some kind of restriction for K
?
No, the # is a type projection. In your case however that does not work because K does not define any BAR type.
trait A {
type T
def apply():T
}
trait MyClass[X<:A] {
type SomeType = X#T
def applySeq():Traversable[SomeType]
}
class AImpl extends A {
type T=Int
def apply():Int = 10
}
class MyClassImpl extends MyClass[AImpl] {
def applySeq(): Traversable[SomeType] = List(10)
}
That basically let you use the type T in A inside MyClass .
In fact, also the following compile:
class MyClassImpl extends MyClass[AImpl] {def applySeq(): Traversable[Int] = List(10)}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With