I am totally new to programming with Scala and I have the following problem:

I need a HashMap which can contain many data types (Int, String, etc..). In C++ I would use BOOST's MultiMap. I have heard that in Scala there is a MultiMap trait available. Basically what I want to to is the following:

```
val map = HashMap[String, ListBuffer[_]]

```

The concrete datatype of the ListBuffer's elements are to be determined during runtime. When I test this implementation in console the following works:

```
scala> val a = new HashMap[String, ListBuffer[_]]()
a: scala.collection.mutable.HashMap[String,scala.collection.mutable.ListBuffer[_]] = Map()

scala> val b = new ListBuffer[String]()
b: scala.collection.mutable.ListBuffer[String] = ListBuffer()

scala> val c = new ListBuffer[Int]()
c: scala.collection.mutable.ListBuffer[Int] = ListBuffer()

scala> b += "String"
res0: b.type = ListBuffer(String)

scala> c += 1
res1: c.type = ListBuffer(1)

scala> a += "String Buffer" -> b
res2: a.type = Map((String Buffer,ListBuffer(String)))

scala> a += "This is an Int Buffer" -> c
res3: a.type = Map((String Buffer,ListBuffer(String)), (This is an Int Buffer,ListBuffer(1)))

```

So basically it works. My first question is, whether there is a possiblity to implement the same behaviour in Scala without using the ListBuffer as layer of indirection.

E.g getting a Map with the following content: Map((String, 1),(String, "String value"), ...)

When I am now trying to use the ListBuffer-Implementation above, I get the following type mismatch error:

```
found   : _$1 where type _$1
required: _$3 where type _$3

```

I am basically trying to do the following:

I use an iterator to iterate over the map's keys:

```
var valueIds = new ListBuffer[Int]()
val iterator = map.keys
iterator.foreach(key => { valueIds += setValue((map.apply(key)).last) }

```

setValue returns Int and is a method which has to do something with the ListBuffers last element.

Does anybody know how to fix the above mentioned type mismatch?

Thanks for your help!

Regards