title: How to invert ternary conditional expression depending on boolean value?
body: <p>I am looking for a way to invert a conditional expression based on a boolean parameter. Of course, this could be done the following way:</p>
  
  <pre><code>public int do(bool b)
  {  
      if (b)
         return this.a ? 1 : 0;
      else 
         return this.a ? 0 : 1;
  }
  </code></pre>
  
  <p>However, it would be helpful to make this whole function a one-liner. So, in terms of logical expressions, I am looking for an operation &compfn;  to combine <code>a</code> and <code>b</code> in a way that</p>
  
  <p>a &compfn; b = a</p>
  
  <p>a &compfn; (&not;b) = &not;a</p>
  
  <p><strong>Question:</strong> Is there such a logical operation (or combination of operations)?</p>