object Test1 extends App {
object specificTypes extends Enumeration {
type specificTypes = Value
val Red = Value
val Green = Value
val Blue = Value
}
abstract class outer {
type T <: Test1.specificTypes.Value
def pr(w: T)
}
class red extends outer {
type T = Test1.specificTypes.Red // Getting Error Here, type Red is not a member of object Test1.specificTypes
def pr(w: T) = println("hello red")
}
val r = new red
r.pr(Test1.specificTypes.Red)
}
유형 레드 개체 Test1.specificTypes
의 구성원이 아닌, 그것을 해결하는 방법, 나는 당신이 원하는 경우 동반자 객체의 타입 T를 저장하는 것이 좋습니다 생각유형 매칭
여기에서 달성하려는 것은 무엇입니까? 더 많은 정보가 필요합니다 – pamu
일반적으로 ADT를 사용합니다 :'sealed trait Colour'' 사례 오브젝트 Red Extour Colour' 등 ... –
타입이있는 클래스가 있습니다. 클래스를 구분하고 싶습니다. 패턴 일치 유형으로 –