I have seen some developers use the return statement in a catch block. Why/when would this be a useful technique to employ?
EDIT: I actually just saw the return keyw
public void Function() {
try
{
//some code here
}
catch
{
return;
}
}
when return; is hit, the execution flow jumps out of the function. This can only be done on void methods.
EDIT: you do this if you dont want to execute the rest of the function. For example if you are doing file IO and a read error happens, you dont want to execute code that handles processing the data in that file since you dont have it.