Created
December 24, 2013 06:21
-
-
Save Centaur/8109498 to your computer and use it in GitHub Desktop.
MyType example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import reflect._ | |
class Father[T <: Father[T] : ClassTag]{ | |
def createInstance: T = implicitly[ClassTag[T]].runtimeClass.newInstance.asInstanceOf[T] | |
} | |
class Child1 extends Father[Child1] | |
class Child2 extends Father[Child2] | |
assert(new Child1().createInstance.isInstanceOf[Child1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment