If you specify a controlling statement such as while, the exit statement must be enclosed by the controlling statement and must be in the same function.

The exit statement causes processing to continue with the referenced statement.
package client;
program MyProgram
function main()
i int = 3;
myLabel1: while(i == 3)
SysLib.writeStdOut("labeled");
for(x int from 1 to 5)
Syslib.writeStdOut("in for loop for x = " + x);
if(x == 4)
syslib.writeStdOut("x = " + x);
i = 4;
exit myLabel1;
end
end
end
syslib.writestdout("leaving");
end
| Target | Issue |
|---|---|
| Java | No issues |
| JavaScript | Support is provided only for following variations of the exit statement: exit case, exit for, exit if, and exit while. |