Nicholas S. answered 07/03/19
Robotics Software Engineer
From my experience it depends on your program. I have written programs with many return statements even ones where the return statement is in the beginning of the function. For example let say you have a function that you only want to run if x > 5. You can do a quick check at the start of the function to see if x > 5 and if not return. If it is you continue. It is more efficient to run the quick check then running through the code the return is all about efficiency.
Now if you have a switch statement like this:
...
{
case 'a':
"do something with x"
return x;
case 'b'
"do something different with x"
return x;
case 'c'
"do something different with x"
return x;
}
you might as well just pull the return out of the case and return it at the end. I hope this helps