Invert bool if true

boolean, java

Solution

The shortest way is

value ^= condition;

Problem

What is the most condense way to invert a boolean if another boolean is true. In other words, what is the shortest way of writing `condition ? !value : value`, preferably evaluating `value` only once? Edit: Just so you know, I am passing the result to a method

Original source

Related problems