Last active
July 31, 2019 15:18
-
-
Save varmas/37c9fa500794af389f5fa62be5834284 to your computer and use it in GitHub Desktop.
dynamic class instantiation in scala [using inheritance]
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 ABC { | |
def foo(bar: String): String = s"wololo.... $bar" | |
} | |
class CDA extends ABC | |
object ABCRunner { | |
def main(args: Array[String]) { | |
val baz = Class.forName("a.b.c.CDA").newInstance.asInstanceOf[ABC] | |
println(baz.foo("boo")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment