Error adding element to mutable Seq

Viewed 2203

I'm wondering, why this doesn't work:

import scala.collection.mutable
var array: mutable.Seq[Int] = mutable.ArrayBuffer[Int]()
array += 5

I get an error stating that += works only for strings, why is this?

error: value += is not a member of scala.collection.mutable.Seq[Int]
  Expression does not convert to assignment because:
    type mismatch;
     found   : Int(5)
     required: String
    expansion: array = array.$plus(5)
       array += 5
             ^
1 Answers
Related