J-M-L:
and luck because the authors have selected the same value as true and false for HIGH and LOW)
I consider it more good design than luck.
J-M-L:
If you care, this should be written as condition ? HIGH : LOW.
Of course that causes the compiler to generate extra code to translate any non-zero value to one. Fortunately for me I'm not a purist and can understand:
boolean inputState = !digitalRead(InputPin);
digitalWrite(OutputPin, !inputState);
A purist would have to write:
int inputState = digitalRead(InputPin) == HIGH ? LOW : HIGH;
digitalWrite(OutputPin, inputState == LOW ? HIGH : LOW);
I wonder if the compiler is smart enough to generate the same code for both. I assume it will at least store a 'boolean' in a byte but an 'int' as two bytes, even though it is used for 1/0 values.