Simple Evaluation
Simple expressions can be passed directly to evaluate them.
Object result = ScriptEngine.getInstance().eval('1 + 2 * (3 - 1)');
Simple expressions can be passed directly to evaluate them.
Object result = ScriptEngine.getInstance().eval('1 + 2 * (3 - 1)');
We can also pass in a context with variables to evaluate the expression.
Map context = new Map{
'a' => 1,
'b' => 2
};
Object result = ScriptEngine.getInstance().eval('a + b', context);
Assignment expressions and function invocations are not supported in evaluation of JavaScript expressions.
Contribute on Github! Edit this section.