Sunday, 8 September 2013

Specifying the requirements for a generic type

Specifying the requirements for a generic type

I want to call a constructor of a generic type T, but I also want it to
have a specific constructor with only one Int argument:
class Class1[T] {
def method1(i: Int) = {
val instance = new T(i) //ops!
i
}
}
How do I specify this requirement?

No comments:

Post a Comment