Does Painless support immediately-invoked function expressions (IIFEs)? For reasons (I'd prefer not to explain them) I need to return the result of several expressions to an if-statement, as shown in an example below.
if ( (function () { def x = false; return !x; })() ) {
// -- do something.
}
I haven't found a way to get IIFE's working in Painless, are they supported?
Just to clarify, I can't write
boolean someFn () {
def x = false;
return !x;
}
def condition = someFn();
if (condition) {
// -- do something
}
I don't believe Painless supports this directly, but you can fake it by creating a method that takes a BooleanSupplier (or whatever other functional interface you need) and just returns the result:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.