With Scala 2.8.1, compiling this:
val t = (40, 2)
println(for ((i, j) <- List(t)) yield i + j)
val e: Either[String, (Int, Int)] = Right(t)
println(e.right.map {
case (i, j) => i + j
})
println(for ((i, j) <- e.right) yield i + j)
gives this:
test.scala:9: error: constructor cannot be instantiated to expected type;
found : (T1, T2)
required: Either[Nothing,(Int, Int)]
println(for ((i, j) <- e.right) yield i + j)
According to Programming in Scala, the for expression should be equivalent to the map/case expression, but only the latter compiles. What am I doing wrong, and how should I do this?