Last active
December 12, 2015 08:19
-
-
Save fwbrasil/4743435 to your computer and use it in GitHub Desktop.
SMirror - invoking a no-arg constructor
This file contains 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
scala> import net.fwbrasil.smirror._ | |
import net.fwbrasil.smirror._ | |
scala> implicit val mirror = runtimeMirror(getClass.getClassLoader) | |
mirror: reflect.runtime.universe.Mirror = JavaMirror with scala.tools.nsc.interprete... | |
scala> case class Shop(store: String, item: String, cost: Int) { | |
| def this() = this(null, null, 0) | |
| } | |
defined class Shop | |
scala> val sClass = sClassOf[Shop] | |
sClass: net.fwbrasil.smirror.SClass[Shop] = Shop | |
scala> sClass.constructors.find(_.parameters.isEmpty).get.invoke() | |
res0: Shop = Shop(null,null,0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://github.com/fwbrasil/smirror