I’m getting a compiler error which I don’t understand. I’ve tried to reduce the test case to some code which exhibits the error, but the code is now pretty useless.
Nevertheless, it would be great if someone could help me understand what the error means. It would be great if someone could have me some insight into what the real problem is here.
ScalaFiddle.scala:25: error: type mismatch;
found : immutable.this.Iterable[scala.this.Int]
required: scala.this.Option[?]
(rectified: Int, cla: Set[Int]) <- rectHashA
I’ve created a ScalaFiddle to show the problem.
The code is also here in a much simpler form than the actual code in my application. If I comment out the line rectHashB: H1 <- lengthHashB.get(length)
when the problem goes away.
def foldups(ups:Iterable[Int]):Int = {
ups.sum
}
type H1 = Map[Int, Set[Int]]
type H2 = Map[Int, H1]
val h1:H1 = Map(1 -> Set(1,2,3))
val h2:H2 = Map(1 -> h1)
val hash:Map[Int,H2] = Map(1 -> h2)
def reducePosCountClauses(posCount: Int): Double = {
val dummy:Int = 0
(hash.get(posCount), hash.get(posCount - 1)) match {
case (None, _) => dummy
case (_, None) => dummy
case (Some(lengthHashA: H2), Some(lengthHashB: H2)) =>
foldups(for {
(length: Int, rectHashA: H1) <- lengthHashA
rectHashB: H1 <- lengthHashB.get(length)
(rectified: Int, cla: Set[Int]) <- rectHashA
if cla.nonEmpty
} yield dummy
)
}
}