Last active
December 17, 2015 05:49
-
-
Save ryanmr/5561235 to your computer and use it in GitHub Desktop.
which do you like better? else if on the same bracket line or on their own new line?
This file contains 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
void ABStar::Final() { | |
platform->enter_state(); | |
if ( platform->get_nextChar() == 'a' ) { | |
platform->set_outputBuffer("In Final, found A"); | |
platform->next_state(); | |
NeedB(); | |
} else if ( platform->get_nextChar() != '\0' ) { | |
platform->set_outputBuffer("In Final, found something other than B"); | |
platform->next_state(); | |
Error(); | |
} else if ( platform->get_nextChar() == '\0' ) { | |
platform->set_outputBuffer("In Final, exiting."); | |
platform->next_state(); | |
} | |
} | |
// -- ^^^ new ^^^ -- ;; no extra parentheses | |
void ABStar::Final() { | |
platform->enter_state(); | |
if (( platform->get_nextChar() == 'a' )) { | |
platform->set_outputBuffer("In Final, found A"); | |
platform->next_state(); | |
NeedB(); | |
} else if (( platform->get_nextChar() != '\0' )) { | |
platform->set_outputBuffer("In Final, found something other than B"); | |
platform->next_state(); | |
Error(); | |
} else if (( platform->get_nextChar() == '\0' )) { | |
platform->set_outputBuffer("In Final, exiting."); | |
platform->next_state(); | |
} | |
} | |
// -- or -- | |
void ABStar::Final() { | |
platform->enter_state(); | |
if (( platform->get_nextChar() == 'a' )) { | |
platform->set_outputBuffer("In Final, found A"); | |
platform->next_state(); | |
NeedB(); | |
} | |
else if (( platform->get_nextChar() != '\0' )) { | |
platform->set_outputBuffer("In Final, found something other than B"); | |
platform->next_state(); | |
Error(); | |
} | |
else if (( platform->get_nextChar() == '\0' )) { | |
platform->set_outputBuffer("In Final, exiting."); | |
platform->next_state(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment