title: How to use ListBuffer in scala?
body: <p>I have a situation where I am passing a single element list to a method. Within this method, the single element in the list is incremented by one. So that after method call, the list first element is modified ( incremented by one).</p>
  
  <p>Code is like this:</p>
  
  <pre><code>val ct = List(5)
  
  someMethod(ct)
  
  println (ct(0))
  
  // should print 6
  </code></pre>
  
  <p>......</p>
  
  <pre><code>//within somethod, I incrment the element like:
  def someMethod(ct: List[Int}) {
      ct(0) = ct(0) + 1
  }
  </code></pre>
  
  <p>Of course above code does not work in Scala. I looked at <a href="http://www.scala-lang.org/api/2.8.1/scala/collection/mutable/ListBuffer.html">ListBuffer</a> but I find the scala doc hard to follow. Scala doc is divided into 2 groups: Type Members and Value Members. In type member there is class WithFiler and value members has many methods. How can I use WithFiler ( probably not directly related to this question but I want to understand how to make use of scala doc). </p>
  
  <p>ListBuffer seems to be the right solution for this problem if I want to have very high performance (the someMethod is called millions of times) ( correct me if I am wrong).</p>
  
  <p>So how to solve above problem if ListBuffer is the right type of list and if not what is the solution?</p>