title: Ruby local variable is undefined
body: <p>I have the following Ruby code:</p>
  
  <pre><code>local_var = "Hello"
  
  def hello
    puts local_var
  end
  
  hello
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>local_variables.rb:4:in 'hello': undefined local variable or method 'local_var' 
  for main:Object (NameError) from local_variables.rb:7:in '&lt;main&gt;'
  </code></pre>
  
  <p>I always thought that local variables are not accessible from outside of the block, function, closure, etc.</p>
  
  <p>But now I defined local variable in the file and try to get an access from the function  <strong>INSIDE</strong> the same file. </p>
  
  <p>What's wrong with my understanding? </p>