From chapter 5 of the specification (eg_6.whiley), the example for continue:
function sumNonNegative(int[] xs) -> int:
int i = 0
int r = 0
while i < |xs|:
if xs[i] < 0:
continue
r = r + xs[i]
i = i + 1
return r
While this example demonstrates the continue statement, it also will cause an endless loop if the array actually contains a negative value (because the i = i + 1 is also skipped).
I'm not sure how this example could be fixed to do what the function name pretends, and still use continue.
From chapter 5 of the specification (eg_6.whiley), the example for
continue
:While this example demonstrates the
continue
statement, it also will cause an endless loop if the array actually contains a negative value (because thei = i + 1
is also skipped).I'm not sure how this example could be fixed to do what the function name pretends, and still use
continue
.