This works
val keys Option[List[Option[String]]] = someFunctionThatReturnsKeys()
val tries = for (
unwrapped <- keys) {
for(keyOption <- unwrapped;
stripped <- keyOption if stripped.contains(":"))
yield Try(java.lang.Long.parseLong(stripped.substring(stripped.lastIndexOf(":") + 1))) }
This does not work.
val tries = for (
unwrapped <- keys;
keyOption <- unwrapped;
stripped <- keyOption if stripped.contains(":"))
yield Try(java.lang.Long.parseLong(stripped.substring(stripped.lastIndexOf(":") + 1)))
The error is for the line
keyOption <- unwrapped;
The error is displayed as
type mismatch; found : List[scala.util.Try[Long]] required: Option[?]
I am using eclipse ide with scala 2.10
Why is the type inference failing?