title: Scala - mutable (var) method parameter reference
body: <p>EDIT: I keep getting upvotes here. Just for the record, I no longer think this is important. I haven't needed it since I posted it.</p>
  
  <p>I would like to do following in Scala ...</p>
  
  <pre><code>def save(srcPath: String, destPath: String) {
      if (!destPath.endsWith('/'))
          destPath += '/'
      // do something
  }
  </code></pre>
  
  <p>... but I can't beacuse <code>destPath</code> is a val. Is there any way to declare <code>destPath</code> as var?</p>
  
  <p>Note: there are similar questions but in all of them OP just wanted to modify array.</p>
  
  <p>Please do not advise following:</p>
  
  <blockquote>
    <p>Mutating the input parameters is often seen as bad style and makes it
    harder to reason about code.</p>
  </blockquote>
  
  <p>I think it's valid in imperative programming (Scala allows both, right?) and adding something like <code>tmpDestPath</code> would just add clutter.</p>
  
  <p>EDIT: Don't misunderstand. I know that strings aren't mutable and I don't want a reference to reference because I don't want to modify data of caller. I just want to modify local reference to string that caller gave me with my string (eg. orig + '/'). I want to modify that value only in scope of current method. Look, this is perfectly valid in Java:</p>
  
  <pre><code>void printPlusOne(int i) {
      i++;
      System.out.println("i is: " + i);
      System.out.println("and now it's same: " + i);
  }
  </code></pre>
  
  <p>I don't have to create new variable and i don't have to compute i+1 twice.</p>