title: How can a variable have a value and also not be defined?
body: <p>I am trying to learn ruby, and have come across something strange. This code:</p>
  
  <pre><code>if defined? branch
      puts "param: #{branch}\n"
  else
      puts "no branch! #{branch}\n"
  end
  </code></pre>
  
  <p>Outputs "no branch! thisisateststring\n", where 'thisisateststring' is the value that has been assigned to the variable branch earlier in the program. How can it be that the variable <code>branch</code> can have a value assigned to it, but not be defined?</p>
  
  <p>Edit:</p>
  
  <p>People seem to not be understanding my question. I am not asking you to figure out why, in this specific instance, the <code>else</code> is being executing; I am asking <em>how can this happen</em> in general. To put it another way, what code would need to be inserted before this, to cause my case to occur?</p>
  
  <p>As I said, I am new to ruby, so I could easily be misunderstanding something basic. I am not trying to solve a specific problem; I am trying to improve my understanding, by learning more about how ruby works. In this instance, how ruby could output a string, while still thinking it is not defined.</p>