score:-1

I found a suitable solution in the comments of the question I linked too.

val (matched, unmatched) =
  finalMatch.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 only issue with this is it leads to type erasure. I've opened another question to discuss this issue.

Dealing with Type Erasure with foldLeft

Thanks all.


Related Query

More Query from same tag