title: Ruby 2.2.4 lexing an assignment in a conditional
body: <p>What is the difference between these two lines of code?</p>
  
  <pre><code>a = (b if (b = "test"))
  a =  b if (b = "test")
  </code></pre>
  
  <p>The first runs fine and sets both <code>a</code> and <code>b</code> to <code>test</code>, but the second throws an error:</p>
  
  <blockquote>
    <p>NameError: undefined local variable or method `b' for main:Object</p>
  </blockquote>
  
  <p>I would have assumed that for the second line, Ruby would evaluate <code>b = "test"</code> first, then <code>if "test"</code>,  and finally <code>a = b</code>. What is actually going on?</p>
  
  <p>(Ruby version 2.2.4)</p>