Forked from anonymous/for-switch state machine
Last active
December 15, 2015 19:29
-
-
Save Plutor/5311872 to your computer and use it in GitHub Desktop.
Pseudo-code of some code I'm refactoring. WTF.
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
bool for_switch_state_machine_wtf() { | |
int state = 1 | |
for(;;) { | |
switch(state) { | |
case 1: | |
if (!do_some_stuff()) | |
return false; | |
state = 2; | |
break; | |
case 2: | |
if (!do_some_other_stuff()) | |
return false; | |
return true; | |
default: | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment