I want to merge multiple maps that are in a list. Each map has two key-value pairs.
What I have...
val input = List[Map[String, String]]
Map[a -> b, c -> d],
Map[a -> b, c -> e],
Map[a -> f, c -> h]
What I want...
val output = Map[String, List[String]]
Map[b -> (d, e), f -> (h)]
I've researched but the closest I could find was this (Scala: Merge maps by key), which is not the scenario I am looking for. Ideally, I would appreciate an explanation rather than just a line of code. I know this can be done with for-loops, but I am trying to learn the Scala way of merging maps.
EDIT: After some discussion in the comments, I decided to simplify the question a bit. The keys 'a' and 'c' are static/not relevant/can be hard coded.
The goal is to make new maps, where the value associated with key 'a' would be the key, and the value associated with key 'c' would be the value. Once all the new maps are made, the ones with a similar key can be grouped together, and all their values can be placed in a list.