The compiler must know how to create instances of type T. In the traditional Java method of handling generics using type erase, this cannot be done intelligently; the compiler simply says, βHey, I donβt know what T is, so I donβt feel so good that I let you instantiate T.β In Scala, however, there is a word for this: manifestos. To enable the manifest for T, simply change the first line of this code to
class MyClass[T : Manifest] {
What is it.
source share