Skip to content

Instantly share code, notes, and snippets.

@fwbrasil
Last active December 12, 2015 08:19
Show Gist options
  • Save fwbrasil/4743435 to your computer and use it in GitHub Desktop.
Save fwbrasil/4743435 to your computer and use it in GitHub Desktop.
SMirror - invoking a no-arg constructor
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)
@fwbrasil
Copy link
Author

fwbrasil commented Feb 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment