Skip to content

Instantly share code, notes, and snippets.

Created August 10, 2017 06:31
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 anonymous/025fda3c45603a5c18c88bed625daede to your computer and use it in GitHub Desktop.
Save anonymous/025fda3c45603a5c18c88bed625daede to your computer and use it in GitHub Desktop.
the description for this gist
// builds an expression like: println(s"$text ${a + (b + 1)}")
def buildComplexExpression(text: String, a: Int, b: Int) = new ScalaToLanguageBridge[String] {
override def apply[Wrapper[_]](implicit F: Language[Wrapper]): Wrapper[String] = {
val addition = F.add(F.number(a), F.increment(F.number(b)))
F.concat(F.text(text), F.toString(addition))
}
}
val fullExpression = buildComplexExpression("Result is ", 10, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment