title: Simplifying statements
body: <p>I am working on a project and I am using Intellij IDEA. While I was writing I got a notification that my if-statement could be simplified. (Note that I am still new to coding)</p>
  
  <p>It says:</p>
  
  <p>Reports if statements which can be simplified to single assignment or return statements.
  For example:</p>
  
  <pre><code>if (foo()) {
     return true;
  } else {
     return false;
  }
  </code></pre>
  
  <p>can be simplified to</p>
  
  <pre><code>return foo();
  </code></pre>
  
  <p>How does this work?
  Say foo() is the number 4, wouldn't this just return 4 instead of true? What am I misunderstanding?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is the code I am writing:</p>
  
  <pre><code>if (row &gt; 0 &amp;&amp; row &lt; 4 &amp;&amp; col &gt; 0 &amp;&amp; col &lt; 4) {
      return false;
  } else {
      return true;
  }
  </code></pre>
  
  <p>and it can be simplified to:</p>
  
  <pre><code>return !(row &gt; 0 &amp;&amp; row &lt; 4 &amp;&amp; col &gt; 0 &amp;&amp; col &lt; 4);
  </code></pre>
  
  <p>I just don't understand how this is simplified. </p>