Created
March 6, 2014 02:42
-
-
Save brentsowers1/9381244 to your computer and use it in GitHub Desktop.
Creating a new instance of a generic class
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
class DynamicTestClass() { | |
def output() { | |
println("Hello from a dynamically sent class") | |
} | |
} | |
def testFunc[T : Manifest]() : T = { | |
manifest[T].erasure.newInstance().asInstanceOf[T] | |
} | |
val dynamicTestClassInstance = testFunc[DynamicTestClass]() | |
dynamicTestClassInstance.output() |
Jacke
commented
Apr 27, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment