title: How do I pass by reference in Scala? with a ListBuffer
body: <p>I want to pass an object in Scala by reference.</p>
  
  <p>The pseudo code is something like</p>
  
  <pre><code>var list1 = List(//stuff in here)
  var list2 = List(//stuff in here).toBuffer
  
  list1.forEach(element =&gt; foo(element,list2)
  
  
  def foo(element,list2){
    remove something from list 2
  }
  </code></pre>
  
  <p>so on each iteration of the forEach, list2 would be different :/
  What would be the best way to do this on scala. Thanks :D</p>