Skip to content

Instantly share code, notes, and snippets.

Created Aug 10, 2017
Embed
What would you like to do?
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