Search code examples
listscaladictionaryscala-collectionsmutable

Converting a Map to a List in Scala without map keys?


How can I convert a map to a list without the map keys being involved in the list in scala?

val mp = collection.mutable.Map[Long, String]()
mp(0) = "val0"
mp(1) = "val1"
mp(2) = "val2"
mp.toList //I want: List("val0", "val1", "val2")

Solution

  • You are probably looking for

    mp.values.toList