title: Convincing a colleague about their if not being nested
body: <p>One of my university colleagues, who has started programming this year, sometimes writes if statements like this:</p>
  
  <pre><code>if(something) doA();
  else
      if(something2) doC();
      else doD();
  </code></pre>
  
  <p>He is conviced that the second <code>if-else</code> pair is treated as a single entity, and that it is in fact nested under the first <code>else</code>.</p>
  
  <p>I'm, however, sure that his code is equivalent to:</p>
  
  <pre><code>if(something) doA();
  else if(something2) doC();
  else doD();
  </code></pre>
  
  <p>This shows that the second else is not actually nested, but on the same level as the first if. I told him he needs to use curly braces to achieve what he wants to. </p>
  
  <p><em>"But my code works as intended!"</em></p>
  
  <p>And indeed, it worked as intended. Turns out the behavior of the code was the same, even if the <code>else</code> was not nested.</p>
  
  <p>Surprisingly, I have found myself unable to write a clear and concise example that shows different behavior between</p>
  
  <pre><code>if(something) doA();
  else
      if(something2) doC();
      else doD();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if(something) doA();
  else {
      if(something2) doC();
      else doD();
  }
  </code></pre>
  
  <p>Can you help me find an example that will show my colleague the difference between using/not using curly braces? </p>
  
  <p>Or is the incorrect-looking version always equivalent to the one with curly braces, in terms of behavior?</p>