Created
December 1, 2010 15:33
-
-
Save mauricio/723642 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int method( int a, int b, int c ) { | |
| int result = a; | |
| if ( a + b > c ) { | |
| result = a + b; | |
| } | |
| return result; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.