I want to convert a Set
to a Map
, something like:
val x: Set[String] = Set("asds", "reqrq", "dadas")
x.fold(Map.empty[String, String]) {
(p: Map[String, String], q: String) => p + (q -> doSomething(q))
}
But I get the following error:
type mismatch;
found : (Map[String,String], String) => scala.collection.immutable.Map[String,String]
required: (Object, Object) => Object
val res16 = x.fold(Map.empty[String, String]) { (p: Map[String, String], q: String) => p + (q -> doSomething(q)) }
^
How does one elegantly achieve this?