0

How do you use an increment operator for booleans so every time it adds ++, it changes from true to false or from false to true?

Allen Rhodes
  • 56
  • 1
  • 1
  • 9

1 Answers1

1

There is no way to toggle a boolean with ++ operator as those are generally applied on numbers. In case you want to toggle your boolean from false to true and true to false. U can use inversion operator e.g. myBoolean = !myBoolean;

Sagar Kharab
  • 369
  • 2
  • 18