Would someone be able to help me convert Map[String, List[String]] to a Map[String, String] in scala?
Here is the Map[String, List[String]] as follows:
val pets: Map[String, List[String]] = Map(
"home" -> List("cat", "dog", "fish"),
"farm" -> List("cow", "horse"),
"wild" -> List("tiger", "elephant")
)
That needs to be converted to Map[String, String] as follows:
val pets2: Map[String, String] = Map(
"home" -> "cat",
"home" -> "dog",
"home" -> "fish",
"farm" -> "cow",
"farm" -> "horse",
"wild" -> "tiger",
"wild" -> "elephant"
)