Skip to content

Instantly share code, notes, and snippets.

@mauricio
Created December 1, 2010 15:33
Show Gist options
  • Select an option

  • Save mauricio/723642 to your computer and use it in GitHub Desktop.

Select an option

Save mauricio/723642 to your computer and use it in GitHub Desktop.
int method( int a, int b, int c ) {
int result = a;
if ( a + b > c ) {
result = a + b;
}
return result;
}
@mauricio
Copy link
Author

mauricio commented Dec 1, 2010

In this case, the first option is quite better, but the second one isn't too bad.

Unfortunately giving people the freedom to do whatever they want (and use as many returns as they want) would lead to bizarre and awlful code, like a single method that returned more than 200 times, as I've already seen.

Also, languages that allow implicit returns do not suffer from this problem in the first case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment