title: Scala - Global variable get the value in a function
body: <p>I am a beginner of Scala.</p>
  
  <p>I immediately get a problem.</p>
  
  <p>Let's say:</p>
  
  <p>I have a Vector variable and 2 functions. The first one function is calling 2nd function. And there is a variable in 2nd function is what I need to get and then append it to Vector. (Without returning the variable in 2nd function.)</p>
  
  <p>The structure looks like this:</p>
  
  <pre><code>def main(args: Array[String]): Unit = {
      var vectorA = Vector().empty
  
  }
  def funcA(): sometype = {
      ...
      ...
      ...
      funcB()
  }
  def funcB(): sometype = {
      var error = 87
  
  }
  </code></pre>
  
  <p>How can I add error variable in global Vector?</p>
  
  <p>I tried to write <code>vectorA :+ error</code> but in vain.</p>