Search code examples
javaxtend

Java xtend funny compile error : This expression is not allowed in this context, since it doesn't cause any side effects


I have an error that does not make sense: This expression is not allowed in this context, since it doesn't cause any side effects. Here is the scenario in which the compile error is risen.

for (var i = 0; i < result.length; i++) {
    if(!validationMustReturnTrue()){
         continue; // this line is mark in error
    }
}

It is a simple for in which I want to skip to the next result on a certain condition.

What does that error mean?

And how do you continue to next value in Xtend? found this group discussion on the continue question. https://groups.google.com/forum/#!topic/xtend-lang/A8YV2JMeodk. continue is not supported in Xtend, but what does the error mean?


Solution

  • Your continue does not change control flow. There is no code that it would prevent from executing.

    Try adding some statements after if inside the loop and see if you still get the error.