Last active
March 21, 2018 05:13
-
-
Save AcnodeLabs/2cada3631cccc079f8ec4c122c120afa to your computer and use it in GitHub Desktop.
Toggle between two variables
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 toggleV1(int v1, int v2) { | |
static short n = 0; | |
if (n==0) { n=1; return v1;} | |
if (n==1) { n=0; return v2;} | |
return 0; | |
} | |
int toggleV2(int v1, int v2) { | |
static bool t = false; | |
t = !t; | |
return (t ? v1 : v2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
V1 can be modified easly to sequence more than 2 values