MCPcopy Index your code
hub / github.com/apache/groovy / xy

Method xy

src/main/java/groovy/util/Eval.java:96–102  ·  view source on GitHub ↗

Evaluates the specified String expression and makes the first two parameters available inside the script bound to variables named 'x' and 'y' respectively, returning the result. For example, this code executes without failure: assert Eval.xy(2, 4, ' x y +

(final Object x, final Object y, final String expression)

Source from the content-addressed store, hash-verified

94 * @throws CompilationFailedException if expression is not valid Groovy
95 */
96 public static Object xy(final Object x, final Object y, final String expression) throws CompilationFailedException {
97 Binding b = new Binding();
98 b.setVariable("x", x);
99 b.setVariable("y", y);
100 GroovyShell sh = new GroovyShell(b);
101 return sh.evaluate(expression);
102 }
103
104 /**
105 * Evaluates the specified String expression and makes the first three parameters available inside

Callers 1

testXYMethod · 0.95

Calls 2

setVariableMethod · 0.95
evaluateMethod · 0.95

Tested by 1

testXYMethod · 0.76