Just assign using the logical NOT operator !
like you tend to do in your condition statements (if
, for
, while
…). You’re working with a boolean value already, so it’ll flip true
to false
(and vice versa):
myBool = !myBool;
Just assign using the logical NOT operator !
like you tend to do in your condition statements (if
, for
, while
…). You’re working with a boolean value already, so it’ll flip true
to false
(and vice versa):
myBool = !myBool;