I want to zip two list and do a pattern matching, but it seems zip and match produce error. I do not know understand why there is such error.
The following example is a simplified version.
This works
val l = List((1, 2), (3, 4), (5, 6))
l.map { case(a, b) => println(s"First is $a, second is $b") }
This does not work
val l1 = List(1,2,3)
val l2 = List(4,5,6)
l1.zip(l2)
l1.zip(l2).map { case(a, b) => a match {case 1 => println(s"First is $a, second is $b") }}
Error info
scala.MatchError: 2 (of class java.lang.Integer)
at .$anonfun$res15$1(<console>:14)
at .$anonfun$res15$1$adapted(<console>:14)
at scala.collection.immutable.List.map(List.scala:287)
... 28 elided