If I have a function as follows:
void func () {
//...
if (condition) {
break;
}
}
When I use break it gives me an error. Is there another way to exit a function using an if condition and to complete compiling the code normally?
use
return;
:if(/*condition*/) { return; }
Just use
return
.More info can be found here.