Hi,
I came across something similar to the following :
serial.println(toggle ? F("OK") : F("NOT OK"))
It prints OK or NOT OK depending toggle being true or false
So this is a conditional printing and it works but I could not find this documented.
Is this C++ / Arduino compliant? Or a shortcut which one is not supposed to use?
system
2
It makes use of the only ternary operator in C. It is perfectly acceptable code.
It is the equivalent of
if (toggle) //toggle is true
{
Serial.println("OK");
}
else //toggle is false
{
Serial.println("NOT OK");
}
It is perfectly valid to use and is not restricted to being used with Serial.print
Thanks PaulS and UKHeliBob for the prompt help!