title: Add objects to a mutable list in scala
body: <p>I've been trying to add data to a mutable list in scala.</p>
  
  <p><strong>I can add basic datatypes fine</strong>, thanks to <a href="http://alvinalexander.com/scala/how-add-elements-to-a-list-in-scala-listbuffer-immutable" rel="nofollow">Alvin Alexanders excellent blog post</a> using a <code>ListBuffer</code> class, but when it comes to objects, Im not really sure how to proceed so please dont mark as duplicate just yet.</p>
  
  <pre><code>import scala.collection.mutable.ListBuffer
  
  var fruits = new ListBuffer[String]()
  fruits += "Apple"
  fruits += "Banana"
  fruits += "Orange"
  </code></pre>
  
  <p>So, I try to map this like so:</p>
  
  <pre><code>import scala.collection.mutable.ListBuffer
  var fruits = new ListBuffer[MyClass]()
  var d1=new MyClass("data1","data2","data3")
  
  fruits += d1
  </code></pre>
  
  <p>This gives the following error:</p>
  
  <pre><code>type mismatch
  found: MyClass
  required: MyClass
  </code></pre>
  
  <p>Can anyone help me here?</p>