Error translating mvel script to groovy

In preparation for the elasticsearch 2.0 upgrade, I noticed that the mvel script was deprecated in favor of groovy. My problem is that I am new to groovy and don’t know how to fix this error.

boolean engineTest = false; if (!engineTest) { engineTest = true;} return engineTest;

This causes the following error:

unexpected token: return @ line 1, column 68. [...]
+4
source share
1 answer

If all this should be on one line, then before the return statement you will not be given a semicolon. How in:

boolean engineTest = false; if (!engineTest) { engineTest = true}; return engineTest;​

Otherwise, you can divide the statements into 3 lines and avoid all half colonies.

+4
source

Source: https://habr.com/ru/post/1615645/


All Articles