It might be, but it isn't since HIGH == 1 and LOW == 0 and ~1 == -2
You probably meant:
digitalWrite (myPin, !digitalRead (myPin));
Or perhaps a bit more obvious to the eye:
digitalWrite (pin, (digitalRead (pin) == HIGH ? LOW : HIGH)) ;
Or the completely verbose
if (digitalRead (pin) == HIGH)
digitalWrite (pin, LOW) ;
else
digitalWrite (pin, HIGH) ;