Skip to content

Instantly share code, notes, and snippets.

@chrislewis
Created December 6, 2011 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislewis/1436818 to your computer and use it in GitHub Desktop.
Save chrislewis/1436818 to your computer and use it in GitHub Desktop.
Scala script file (embedded example)
/*
* Script for an embedded compiler like https://github.com/twitter/util/blob/master/util-eval/src/main/scala/com/twitter/util/Eval.scala
* The script is read as a string and wrapped in a randomly generated subclass of () => Any.
* The contents of the script constitute the body of the generated class' apply method.
* The interpreter loads the generated class, casts to () => Any, and invokes apply, presumably
* casting to a type parameter as needed.
* The end result of an interpreted file is just like a statement in scala: the last value
* is the result (also note that the entire body of the script is scoped to the containing method).
*/
import com.stuff._
new Config(
jdbc = "jbc:mysql....",
mongo = MongoConnection("localhost")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment