Closed SamTebbs33 closed 8 years ago
Correct me if I'm wrong, but here's my understanding of the execution in that block of code:
According to my understanding, this code is pointless as it compares a variable and a value that has already been set to that value, and then sets it to that value again.
You're forgetting about the variable being declared static. Static is the bit that makes this block of code not pointless :P
Oh I see, I personally don't find this one of the most semantic and readable elements of C, as the fact that the variable assignment is inside a code block implies that it happens each time that code block is run.
If ledFlash was not static then it would have been pointless, but the way it is at the moment makes it alternately light up the red and green LEDs. Your code just makes it light up the green LED.