I have a list that contains a mixture of strings and maps, listOfIds
. The code below attempts to this list. Maps into matched and strings to unmatched.
val (matched, unmatched) =
listOfIds.foldLeft(List.empty[Map[String, String]], List.empty[String]) {
case ((matched, unmatched), p) => p match {
case m:Map[String, String] => (m :: matched, unmatched)
case s:String => (matched, s :: unmatched)
}
}
The issue is I'm running into type erasure. I found that I was able to use place holders for the types to get around this m:Map[_, _]
,but this causes issues later on when attempting to extract the map values.
I'm unfamiliar with type tags but quick research suggests that this could be a solution... Would appreciate any points how I could get around type erasure in this instance.
Thanks!