void setup() {
/* Initialize serial and wait up to 5 seconds for port to open */
Serial.begin(9600);
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime > 5000); ) { }
On the first pass, millis() - serialBeginTime will be less than 5000 and, therefore, the loop will exit because the truth condition will be violated.
To me it only makes sense if the > is changed to a < sign since both !Serial and
millis()-serialBeginTime > 5000 need to be true for the loop to wait up to 5 seconds for
Serial to be TRUE
unsigned long const serialBeginTime = millis();
while (!Serial && (millis() - serialBeginTime > 5000)) {}
which will wait as long as the condition is true.
for a AND condition to be true, you need both to be true
so
➜ Serial needs to be uninitialized
AND
➜ waiting time needs to be more than 5s
ÉDIT: It will exit if one condition is false (which is guaranteed to be the second one immediately)