How can you prematurely exit from a function without returning a value if it is a void function? I have a void method that needs to not execute its code if a certain condition i
void foo() { /* do some stuff */ if (!condition) { return; } }
You can just use the return keyword just like you would in any other function.