title: Why is my Scala function returning type Unit and not whatever is the last line?
body: <p>I am trying to figure out the issue, and tried different styles that I have read on Scala, but none of them work. My code is:</p>
  
  <pre><code>....
  
  val str = "(and x y)";
  
  def stringParse ( exp: String, pos: Int, expreshHolder: ArrayBuffer[String], follow: Int )  
  
      var b = pos; //position of where in the expression String I am currently in
      val temp = expreshHolder; //holder of expressions without parens
      var arrayCounter = follow; //just counts to make sure an empty spot in the array is there to put in the strings
  
      if(exp(b) == '(') {
          b = b + 1;
  
          while(exp(b) == ' '){b = b + 1} //point of this is to just skip any spaces between paren and start of expression type
  
          if(exp(b) == 'a') {
                 temp(arrayCounter) = exp(b).toString; 
                 b = b+1; 
                 temp(arrayCounter)+exp(b).toString; b = b+1; 
                 temp(arrayCounter) + exp(b).toString; arrayCounter+=1}
                 temp;
  
           }
  
  }
  
  val hold: ArrayBuffer[String] = stringParse(str, 0, new ArrayBuffer[String], 0);
  for(test &lt;- hold) println(test);
  </code></pre>
  
  <p>My error is:</p>
  
  <pre><code>Driver.scala:35: error: type mismatch;
  found   : Unit
   required: scala.collection.mutable.ArrayBuffer[String]
  ho = stringParse(str, 0, ho, 0);
                  ^one error found
  </code></pre>
  
  <p>When I add an equals sign after the arguments in the method declaration, like so:</p>
  
  <pre><code>def stringParse ( exp: String, pos: Int, expreshHolder: ArrayBuffer[String], follow: Int )  ={....}
  </code></pre>
  
  <p>It changes it to "Any". I am confused on how this works. Any ideas? Much appreciated.</p>