title: Why does this if-statement combining assignment and an equality check return true?
body: <p>I've been thinking of some beginner mistakes and I ended up with the one on the <code>if</code> statement. I expanded a bit the code to this:</p>
  
  <pre><code>int i = 0;
  if (i = 1 &amp;&amp; i == 0) {
      std::cout &lt;&lt; i;
  }
  </code></pre>
  
  <p>I have seen that the <code>if</code> statement returns true, and it <code>cout</code>'s <code>i</code> as <code>1</code>. If <code>i</code> is assigned <code>1</code> in the if statement, why did <code>i == 0</code> return <code>true</code>?</p>