Created
March 12, 2012 00:45
-
-
Save naush/2018923 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
| # multiple exits | |
| if a | |
| code | |
| code | |
| code | |
| if b | |
| code | |
| code | |
| code | |
| return c | |
| else | |
| code | |
| code | |
| code | |
| return d | |
| end | |
| else | |
| code | |
| code | |
| code | |
| return e | |
| end | |
| # single exit | |
| result = nil | |
| if a | |
| code | |
| code | |
| code | |
| if b | |
| code | |
| code | |
| code | |
| result = c | |
| else | |
| code | |
| code | |
| code | |
| result = d | |
| end | |
| else | |
| code | |
| code | |
| code | |
| result = e | |
| end | |
| return result |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context definitely plays a big role here. I can see how early returns can help in some situations, too. Steven's rewrite is a good example.