I'm trying to compare two parallel arrays of strings together. Each array is guaranteed to be the same length. Corresponding strings in each array may be indented differently, so I perform a trim when comparing them. I've written the following function to do the comparison, and I'm getting a match error when I run the code:
def compare(expected: Seq[String], actual: Seq[String]): Boolean = (expected, actual) match {
case (Nil, _) => true
case (a :: _, b :: _) if (a.trim != b.trim) => false
case (_ :: a, _ :: b) => compare(a, b)
}
What am I missing here? As far as I can tell this should cover all cases.
The actual exception:
scala.MatchError: (WrappedArray(ExpectedString), WrappedArray(ActualString)) (of class scala.Tuple2)