Skip to content

Instantly share code, notes, and snippets.

@minosiants
Created March 4, 2017 02:10
Show Gist options
  • Save minosiants/1072c55dddd04ce96452c2ae0d1b9903 to your computer and use it in GitHub Desktop.
Save minosiants/1072c55dddd04ce96452c2ae0d1b9903 to your computer and use it in GitHub Desktop.
Evaluating string as scala code using twitter util-eval
// https://github.com/twitter/util
object Programm extends App {
import com.twitter.util.Eval
type EntryConditionFunc = Map[String, String] => Boolean
val eval = new Eval
val func = eval[EntryConditionFunc]("""(ctx:Map[String, String]) => ctx("name") == "hello" """)
val result = func(Map("name" -> "hello"))
println(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment