I try to learn by deconstructing sample code, but I've never seen this. A return inside of the loop.
//*********************************** Loop ***********************************
void loop() {
// Look for new cards
if ( ! rfid.PICC_IsNewCardPresent())
return;
// Verify if the NUID has been readed
if ( ! rfid.PICC_ReadCardSerial())
return;
What does it return to?
I am just guessing, but does this skip all the code that follows to the end of the loop?
Thank you both for the quick reply.
Is this an acceptable structure, or should I be nesting if statements? I kind of like the idea of skipping to the end if the test fails.
And, Blackfin, thanks. I had never seen the parent code for the sketch.
SteveMann:
Thank you both for the quick reply.
Is this an acceptable structure, or should I be nesting if statements?
It is if it makes your code easier to understand. I often use premature returns to avoid a deeply nested IF structure that would be hard to understand.
Make sure to first do the test that is most likely to fail as that shortens the time for the code in the greatest number of cases.