title: Scala: how to append to a Seq
body: <p>I am struggling with the following piece of code:</p>
  
  <pre><code>type DB = Map[Int, Seq[String]]
  var grades: DB = Map.empty
  def add(name: String, grade: Int) = {
    var names: Seq[String] = Seq(name)
    if(grades isDefinedAt grade) {
      names = names ++ grades(grade)
    }
      grades += (grade -&gt; names)
  }
  </code></pre>
  
  <p>When I call the "add" method, as follow:</p>
  
  <pre><code>add(2, "Mike")
  add(2, "Michelle")
  add(2, "John")
  </code></pre>
  
  <p>I would expect <code>grades</code> to be <code>(2, Seq(Mike, Michelle, John))</code> but, instead, it contains only the last addition <code>(2, John)</code>.</p>
  
  <p>How can I solve that?</p>
  
  <p>Thanks!!!</p>