I’m creating a GWT version of a Java library which has support for the javax.script.ScriptEngine to evaluate functions dynamically via Javascript, e.g.,
o => o % 2 == 0
where at runtime, the value of “o” is defined via the javax.script.Bindings (the o => part is stripped of course).
The problem is, how can I get the same effect from within GWT? I use a native function
native Object nativeEval(String script) /*-{
return $wnd.eval(script);
}-*/
nativeEval("o % 2 == 0");
But how can I bind a value to the identifier “o”?
If
expressionThatUsesOis"o % 2"then this is equivalent to a global function that is immediately calledFor reference, https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function :